Repository navigation
Support Python None defaults in object argument declarations - #9557
Merged
youknowone merged 3 commits intoNov 3, 2026
Merged
Conversation
Contributor
|
Caution Review failedThe pull request is closed.
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. CodeRabbit Verify
|
This was referenced Nov 3, 2026
youknowone
commented
Nov 3, 2026
| fn literal_object_expr(expr: &Expr) -> Option<TokenStream> { | ||
| match expr { | ||
| Expr::Path(path) if path.qself.is_none() && path.path.is_ident("None") => { | ||
| Some(quote!(vm.ctx.none())) |
Member
Author
There was a problem hiding this comment.
No, not this way. Only when the rust type is Option including Option
Generate the None singleton lazily for object defaults while retaining existing Option and OptionalArg Rust-default paths. Cover generated syntax and typed metadata without constructing Python objects. Assisted-by: OpenAI Codex:model version not exposed
Keep the wrapper fallback expectation unchanged while using quote output instead of a manually spaced closure string. Assisted-by: OpenAI Codex:model version not exposed
Remove Python None construction for unwrapped fields. Document existing Option defaults and replace the two newly added object-None tests with Option metadata and literal-boundary checks. Assisted-by: OpenAI Codex:model version not exposed
youknowdot
force-pushed
the
fix-derive-none-default-20261103
branch
from
November 3, 2026 07:03
017500f to
fe4a8e5
Compare
youknowone
marked this pull request as ready for review
November 3, 2026 16:36
youknowone
enabled auto-merge (squash)
November 3, 2026 16:36
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
youknowone
disabled auto-merge
November 3, 2026 16:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Follow up the default=None design question in #9538. For non-primitive, non-wrapped argument fields, lower
#[pyarg(any, default = None)]through the existing lazy Python-object conversion path. The signature already has typed None metadata; the omitted runtime value now uses the None singleton rather than an incompatible Rust Option expression.Option,OptionalArg, andOptionalOptiondefault expressions and omission semantics. This does not reinterpret None asOptionalArg::Missingor remove explicit Clinic display-default overrides.PyObjectRefuses the singleton without allocating another Python object or invoking user callbacks.PyStrRefwith a None default rejects omission through its normal converter, just as incompatible literal defaults already do. This does not bypass type checks or add a compile-time Python type checker.Validation
Independent exact-head source review and normal pre-commit hooks passed; diff check and clean worktree verified. The two affected files are unchanged between base 016cdff and current main 7f50ac2; merge-tree against current main succeeds.
The three new tests have not run locally. Derive/workspace/C-API tests and workspace/C-API Clippy were attempted offline but stopped before compilation because the pinned parking_lot_core git source is missing from the local cache. Exact-head CI compilation and test execution remain pending; this is a Draft PR.
No Lib files, snippets, dependency changes, global argument-shape ordering changes, or runtime-object tests.