GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — correct builtins type under function by youknowone · Pull Request #6745 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Jan 16, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions
@youknowone
correct buitins type
d36e414
@coderabbitai

coderabbitai Bot commented Jan 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
📝 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

  • Pyfunction builtins and constructor #5823: Modifies PyFunction construction and builtins handling in the same core file with overlapping focus areas.
  • SetFunctionAttribute #5968: Changes PyFunction constructor behavior, closure validation, and defaults/kwdefaults field handling in parallel updates.

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
  • 📝 Generate docstrings

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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions
Auto-format: ruff format
a9078b4
@github-actions

github-actions Bot commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone marked this pull request as ready for review January 16, 2026 13:57
@youknowone youknowone changed the title correct buitins type correct builtins type under function Jan 16, 2026
@youknowone
youknowone merged commit e9a57d1 into RustPython:main Jan 16, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone deleted the correct-builtins-type branch January 16, 2026 15:00
@coderabbitai coderabbitai Bot mentioned this pull request Feb 5, 2026
Implement more ast features #6986
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

1 participant

@youknowone
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.