Update some tests from 3.13.7 by ShaharNaveh · Pull Request #6108 · RustPython/RustPython
I can split this PR if it's too big
Summary by CodeRabbit
- New Features
- None.
- Bug Fixes
- Updated unicodedata.name error message when no name is found (with a default provided) to “no such name” for clearer feedback.
- Refactor
- Removed the is_integer method from integer objects; it is no longer available in the public API.
- Chores
- Updated ignore rules for development artifacts under Lib/site-packages and Lib/test/data, while keeping README files.
Walkthrough
Updates ignore patterns in .gitignore. Adjusts unicodedata::name to emit a different ValueError message when no name is found with a default provided. Removes the Python-exposed is_integer method from PyInt, retaining an internal const version; bit_count remains unchanged.
Changes
| Cohort / File(s) | Summary |
|---|---|
VCS ignore rules./.gitignore |
Add ignore patterns for Lib/site-packages/* and Lib/test/data/*; re-include Lib/site-packages/README.txt and Lib/test/data/README. |
Unicode data error textstdlib/src/unicodedata.rs |
Change ValueError text in unicodedata::name when no character name is found with a default: from "character name not found!" to "no such name". No API changes. |
Int builtins method visibilityvm/src/builtins/int.rs |
Remove Python-visible is_integer on PyInt; replace with internal const fn is_integer(&self) -> bool (always true). bit_count unchanged; public signatures otherwise unaffected. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
I nibble through diffs with whiskers bright,
Ignore the clutter, keep paths light.
A name now speaks a shorter tone,
Ints stay integer, but less is shown.
Thump-thump! the repo’s lean and clear—
Carrots for code, see you next peer. 🥕✨
Tip
🔌 Remote MCP (Model Context Protocol) integration is now available!
Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.
✨ Finishing Touches
- 📝 Generate Docstrings
🧪 Generate unit tests
- Create PR with unit tests
- Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.gitignore (1)
24-28: Clarify ignore depth and anchor patterns for Lib/site-packages and Lib/test/dataIf the intent is to ignore everything under these directories recursively (not just direct children), prefer anchoring to repo root and using
**. Keeps the single README files tracked.Would you like these patterns to apply recursively? If yes, apply:
-Lib/site-packages/* -!Lib/site-packages/README.txt -Lib/test/data/* -!Lib/test/data/README +/Lib/site-packages/** +!/Lib/site-packages/README.txt +/Lib/test/data/** +!/Lib/test/data/README
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (35)
Lib/test/data/READMEis excluded by!Lib/**Lib/test/dtracedata/assert_usable.dis excluded by!Lib/**Lib/test/dtracedata/assert_usable.stpis excluded by!Lib/**Lib/test/dtracedata/call_stack.dis excluded by!Lib/**Lib/test/dtracedata/call_stack.d.expectedis excluded by!Lib/**Lib/test/dtracedata/call_stack.pyis excluded by!Lib/**Lib/test/dtracedata/call_stack.stpis excluded by!Lib/**Lib/test/dtracedata/call_stack.stp.expectedis excluded by!Lib/**Lib/test/dtracedata/gc.dis excluded by!Lib/**Lib/test/dtracedata/gc.d.expectedis excluded by!Lib/**Lib/test/dtracedata/gc.pyis excluded by!Lib/**Lib/test/dtracedata/gc.stpis excluded by!Lib/**Lib/test/dtracedata/gc.stp.expectedis excluded by!Lib/**Lib/test/dtracedata/instance.pyis excluded by!Lib/**Lib/test/dtracedata/line.dis excluded by!Lib/**Lib/test/dtracedata/line.d.expectedis excluded by!Lib/**Lib/test/dtracedata/line.pyis excluded by!Lib/**Lib/test/pythoninfo.pyis excluded by!Lib/**Lib/test/site-packages/README.txtis excluded by!Lib/**Lib/test/support/hypothesis_helper.pyis excluded by!Lib/**Lib/test/test_binascii.pyis excluded by!Lib/**Lib/test/test_cmath.pyis excluded by!Lib/**Lib/test/test_contextlib.pyis excluded by!Lib/**Lib/test/test_hashlib.pyis excluded by!Lib/**Lib/test/test_long.pyis excluded by!Lib/**Lib/test/test_math.pyis excluded by!Lib/**Lib/test/test_math_property.pyis excluded by!Lib/**Lib/test/test_opcache.pyis excluded by!Lib/**Lib/test/test_optparse.pyis excluded by!Lib/**Lib/test/test_property.pyis excluded by!Lib/**Lib/test/test_ucn.pyis excluded by!Lib/**Lib/test/test_unicodedata.pyis excluded by!Lib/**Lib/test/translationdata/argparse/msgids.txtis excluded by!Lib/**Lib/test/translationdata/getopt/msgids.txtis excluded by!Lib/**Lib/test/translationdata/optparse/msgids.txtis excluded by!Lib/**
📒 Files selected for processing (3)
.gitignore(1 hunks)stdlib/src/unicodedata.rs(1 hunks)vm/src/builtins/int.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style (cargo fmtto format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass,pymodule,pyfunction, etc.) when implementing Python functionality in Rust
Files:
stdlib/src/unicodedata.rsvm/src/builtins/int.rs
🧬 Code graph analysis (1)
vm/src/builtins/int.rs (2)
compiler/literal/src/float.rs (1)
is_integer(25-27)vm/src/builtins/float.rs (1)
is_integer(480-482)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Check the WASM package and demo
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run tests under miri
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Check Rust code with rustfmt and clippy
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Ensure compilation on various targets
🔇 Additional comments (2)
stdlib/src/unicodedata.rs (1)
148-149: LGTM: ValueError message updated to match CPython behaviorReturning the provided default when no name is found, and otherwise raising
ValueError("no such name")aligns with CPython’s expectations forunicodedata.name.vm/src/builtins/int.rs (1)
693-693: bit_count remains correctly exposed
bit_count()implementation is consistent with Python’s API and semantics.
Comment on lines +689 to +692
| const fn is_integer(&self) -> bool { | ||
| true | ||
| } | ||
|
|
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Do not expose int.is_integer() to Python
int in CPython does not have an is_integer() method; exposing it breaks compatibility and likely contradicts the updated tests. If you need this helper internally, keep it as a non-#[pymethod] function in a non-pyclass impl block; otherwise, remove it.
Apply this diff to stop exporting it to Python:
- #[pymethod] - const fn is_integer(&self) -> bool { - true - }
Optionally, if an internal helper is desired elsewhere in the crate, add (outside the #[pyclass] impl):
impl PyInt { pub const fn is_integer(&self) -> bool { true } }
Run to confirm nothing else exposes is_integer for int:
🏁 Script executed:
#!/bin/bash # grep for Python-visible int.is_integer definitions/usages rg -n --type=rust -C2 '(?m)^\s*#\s*\[pymethod\]\s*\n\s*const?\s+fn\s+is_integer\b' vm/src rg -n --type=python -C2 "hasattr\\([^,]+,\\s*['\\\"]is_integer['\\\"]\\)" Lib/test || true
Length of output: 501
To ensure we didn’t miss any Python-exposed is_integer methods or references, let’s rerun with a corrected regex:
🏁 Script executed:
#!/bin/bash # Search for any #[pymethod] const fn is_integer in Rust rg -n -U --type=rust '#\[pymethod\]\s*const\s+fn\s+is_integer' vm/src # Search for any usage of .is_integer() in Python tests rg -n --type=python '\.is_integer\s*\(' Lib/test
Length of output: 264
Remove Python exposure of int.is_integer()
The #[pymethod] const fn is_integer(&self) -> bool { … } on lines 688–689 of vm/src/builtins/int.rs is still being exposed to Python. In CPython, int has no is_integer() method, so this breaks compatibility.
Please apply the following diff to stop exporting it:
--- a/vm/src/builtins/int.rs +++ b/vm/src/builtins/int.rs @@ impl PyInt { - #[pymethod] - const fn is_integer(&self) -> bool { - true - }
If you still need this helper internally, add it outside the #[pyclass] impl as a plain Rust method:
impl PyInt { pub const fn is_integer(&self) -> bool { true } }
🤖 Prompt for AI Agents
In vm/src/builtins/int.rs around lines 689–692, the const fn is_integer(&self)
is currently exposed to Python via #[pymethod] inside the #[pyclass] impl which
is incompatible with CPython; remove the #[pymethod] export (delete the method
from the pyclass impl) and, if the functionality is still needed internally, add
a plain Rust method on PyInt outside the #[pyclass] impl (e.g., impl PyInt { pub
const fn is_integer(&self) -> bool { true } }) so it is available in Rust but
not exported to Python.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!