Skip to content

Update some tests from 3.13.7 #6108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 24, 2025

Conversation

ShaharNaveh
Copy link
Contributor

@ShaharNaveh ShaharNaveh commented Aug 24, 2025

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.

Copy link
Contributor

coderabbitai bot commented Aug 24, 2025

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 text
stdlib/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 visibility
vm/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.

❤️ Share
🪧 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 @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in 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 ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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/data

If 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 5c6f92d and e7c8796.

⛔ Files ignored due to path filters (35)
  • Lib/test/data/README is excluded by !Lib/**
  • Lib/test/dtracedata/assert_usable.d is excluded by !Lib/**
  • Lib/test/dtracedata/assert_usable.stp is excluded by !Lib/**
  • Lib/test/dtracedata/call_stack.d is excluded by !Lib/**
  • Lib/test/dtracedata/call_stack.d.expected is excluded by !Lib/**
  • Lib/test/dtracedata/call_stack.py is excluded by !Lib/**
  • Lib/test/dtracedata/call_stack.stp is excluded by !Lib/**
  • Lib/test/dtracedata/call_stack.stp.expected is excluded by !Lib/**
  • Lib/test/dtracedata/gc.d is excluded by !Lib/**
  • Lib/test/dtracedata/gc.d.expected is excluded by !Lib/**
  • Lib/test/dtracedata/gc.py is excluded by !Lib/**
  • Lib/test/dtracedata/gc.stp is excluded by !Lib/**
  • Lib/test/dtracedata/gc.stp.expected is excluded by !Lib/**
  • Lib/test/dtracedata/instance.py is excluded by !Lib/**
  • Lib/test/dtracedata/line.d is excluded by !Lib/**
  • Lib/test/dtracedata/line.d.expected is excluded by !Lib/**
  • Lib/test/dtracedata/line.py is excluded by !Lib/**
  • Lib/test/pythoninfo.py is excluded by !Lib/**
  • Lib/test/site-packages/README.txt is excluded by !Lib/**
  • Lib/test/support/hypothesis_helper.py is excluded by !Lib/**
  • Lib/test/test_binascii.py is excluded by !Lib/**
  • Lib/test/test_cmath.py is excluded by !Lib/**
  • Lib/test/test_contextlib.py is excluded by !Lib/**
  • Lib/test/test_hashlib.py is excluded by !Lib/**
  • Lib/test/test_long.py is excluded by !Lib/**
  • Lib/test/test_math.py is excluded by !Lib/**
  • Lib/test/test_math_property.py is excluded by !Lib/**
  • Lib/test/test_opcache.py is excluded by !Lib/**
  • Lib/test/test_optparse.py is excluded by !Lib/**
  • Lib/test/test_property.py is excluded by !Lib/**
  • Lib/test/test_ucn.py is excluded by !Lib/**
  • Lib/test/test_unicodedata.py is excluded by !Lib/**
  • Lib/test/translationdata/argparse/msgids.txt is excluded by !Lib/**
  • Lib/test/translationdata/getopt/msgids.txt is excluded by !Lib/**
  • Lib/test/translationdata/optparse/msgids.txt is 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 fmt to 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.rs
  • vm/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 behavior

Returning the provided default when no name is found, and otherwise raising ValueError("no such name") aligns with CPython’s expectations for unicodedata.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
}

Copy link
Contributor

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.

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@youknowone youknowone merged commit dae9584 into RustPython:main Aug 24, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants