GeezerVison is showing github.com — correct builtins type under function by youknowone · Pull Request #6745 · RustPython/RustPython
Conversation
youknowone
commented
Jan 16, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
-
Refactor
- Improved internal handling of builtin references during function initialization and argument processing, enhancing consistency and reliability of builtin access throughout the function lifecycle.
-
Tests
- Added test validation to verify correct behavior and type checking of function-level builtin attributes.
✏️ Tip: You can customize this high-level summary in your review settings.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jan 16, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
📝 Walkthrough
Walkthrough
The changes refactor PyFunctionNewArgs struct field signatures, converting OptionalArg types to Option, renaming defaults to argdefs, and enhance builtins resolution logic to fallback to vm.builtins.dict() with module unwrapping. The py_new constructor is updated to validate closure length against code.freevars. A test is added to verify that function \builtins resolves to a dict.
Changes
| Cohort / File(s) |
Summary |
PyFunction signature and constructor updates crates/vm/src/builtins/function.rs |
PyFunctionNewArgs struct fields refactored: defaults renamed to argdefs, types changed from OptionalArg to Option; closure and kwdefaults similarly updated. py_new constructor adds closure length validation against code.freevars. Builtins resolution improved with fallback to vm.builtins.dict() and module \dict unwrapping. |
Test coverage extra_tests/snippets/builtins_module.py |
New test function added with runtime assertion that test_func.__builtins__ is a dict instance. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~22 minutes
Possibly related PRs
Poem
🐰 Hoppy defaults find their way,
From OptionalArg to Option's ray,
Closure validation stands so tall,
Builtins unwrapped—dict for all!
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (2 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title 'correct builtins type under function' accurately summarizes the main changes: fixing builtins type handling in function initialization, including struct field changes from OptionalArg to Option types and builtins resolution logic. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
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
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Code has been automatically formatted
The code in this PR has been formatted using:
ruff format
Please pull the latest changes before pushing again:
git pull origin correct-builtins-type
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.