Skip to content

Declare nullable argument defaults directly - #9560

Merged
youknowone merged 4 commits into
RustPython:mainfrom
youknowdot:cleanup-argument-defaults-20261103
Nov 3, 2026
Merged

youknowone merged 4 commits into
RustPython:mainfrom
youknowdot:cleanup-argument-defaults-20261103

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Declare six nullable argument defaults directly in four Rust files:

  • mkfifo.dir_fd
  • pidfd_send_signal.siginfo
  • The shared match groups/groupdict default
  • Three ignored epoll exit arguments

These use Option<PyObjectRef> with default = None. Omission remains a native absent state, with existing lazy None fallbacks retained. Rendered signatures are unchanged; typed None metadata replaces Raw metadata. The existing path, file-descriptor conversion and warning order remain intact. The three epoll exit fields now use their signature names directly, removing redundant name attributes while keeping the ignored owning argument and its drop timing unchanged.

The earlier nine non-None changes have been restored: two compression max lengths, array start, four binascii canonical flags, recursive, and mkfifo mode. Their original native or Missing paths avoid Python default-object construction and conversion. In particular, the current derive implementation does not recognize the PySsize alias as a primitive integer, so changing its defaults here would add boxing and reconversion.

CPython 3.15 source pin: d220409a13b77de7a6c30abe16ea90db01528edc. References: mkfifo, signal, match defaults, epoll exit.

Validation

  • Independent exact-head source review, normal pre-commit hooks, rustfmt and diff checks passed for 04317ac07270288efbb81b8efda97446d95aa32c.
  • No test assertions, test files or Lib files changed.
  • Workspace/C-API tests and Clippy plus canonical test_os, test_epoll, test_signal and test_re were attempted offline. All stopped before compilation because the pinned parking_lot_core git dependency is unavailable locally. No local native test pass is claimed.
  • CI for current head 1fddea5f30be3b846023c9fc6c7ec2da18f9c235 is in progress. The previous run for 04317ac07270288efbb81b8efda97446d95aa32c was cancelled after the author-only rewrite; both heads have identical source trees. The current head's full CI results remain pending.

AI-assisted implementation and review with OpenAI Codex; model version not exposed.

Summary by CodeRabbit

  • Bug Fixes
    • pidfd_send_signal now raises a TypeError when siginfo is explicitly provided as None; omitting the argument continues to use its default. Only an omitted siginfo is accepted, while any explicitly supplied value is rejected. No other user-visible behavior changes are noted in this update.

Declare fifteen concrete argument defaults directly across compression, array, binascii, process helpers, epoll and match methods. Keep bool conversion and argument release at their current body locations, acquired buffer cleanup order, mkfifo path-before-fd conversion, and existing signed bound semantics.

Preserve symbolic, callback-sensitive and stateful omission defaults. No tests, assertions or Lib files changed. Source-reviewed against CPython 3.15.0 d220409a13b77de7a6c30abe16ea90db01528edc; native validation remains limited by the available dependency closure.

Assisted-by: OpenAI Codex:model version not exposed
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

Several standard-library argument wrappers now use Option<PyObjectRef> with direct None defaults. Call-site handling changes in pidfd_send_signal, findall, and mkfifo.

Changes: Nullable argument handling

Layer / File(s) Summary
Epoll and signal arguments
crates/stdlib/src/select.rs, crates/vm/src/stdlib/_signal.rs
EpollExitArgs uses named optional fields. PidfdSendSignalArgs.siginfo uses Option<PyObjectRef>, and pidfd_send_signal rejects any present value, including None.
Regex match defaults
crates/vm/src/stdlib/_sre.rs
DefaultArg.default uses Option<PyObjectRef>. findall passes the empty unmatched-group value as Some(empty.clone()).
mkfifo directory descriptor
crates/vm/src/stdlib/posix.rs
MkfifoArgs.dir_fd uses Option<PyObjectRef>. mkfifo handles Some(fd) and None directly.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Possibly related PRs

Suggested reviewers: youknowone

Merge Risk: Minimal · up to 9b00a

The nullable-default changes preserve the inspected behavior. No merge-blocking issue was identified; normal build and test checks should still complete before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: declaring nullable argument defaults directly instead of through OptionalArg across the affected Rust files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 4 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1fddea5 and 9b00ab3.

Files selected for processing: 1
  • crates/vm/src/stdlib/_sre.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Restore runtime defaults whose concrete literal lowering adds Python object creation, conversion, or reference management on omitted arguments. Keep only cost-preserving None default cleanup, where applicable. No test code or expectations changed.

Assisted-by: OpenAI Codex:model version not exposed
@youknowdot youknowdot changed the title Replace concrete omission wrappers with typed defaults Declare nullable argument defaults directly Nov 3, 2026
Comment thread crates/stdlib/src/select.rs Outdated
_exc_value: OptionalArg,
#[pyarg(positional, optional, name = "exc_tb", py_default = "None")]
_exc_tb: OptionalArg,
#[pyarg(positional, default = None, name = "exc_type")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

when name is not given, prefix single _ must be auto removed

Use the signature names as the Rust field names so explicit name attributes are redundant. Match the existing multiprocessing ExitArgs dead-code annotation for intentionally ignored context-manager arguments; keep the function body and argument lifetimes unchanged.

Assisted-by: OpenAI Codex:model version not exposed
@youknowone
youknowone marked this pull request as ready for review November 3, 2026 04:21
@youknowone
youknowone enabled auto-merge (squash) November 3, 2026 04:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T07:11:05.379512Z 1fddea5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

auto-merge was automatically disabled November 3, 2026 07:07

Head branch was pushed to by a user without write access

@youknowdot
youknowdot force-pushed the cleanup-argument-defaults-20261103 branch from 04317ac to 1fddea5 Compare November 3, 2026 07:07
@codspeed

codspeed Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:cleanup-argument-defaults-20261103 (1fddea5) with main (cc18267)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

The nullable match default no longer uses OptionalArg. Remove the stale import so Clippy with -Dwarnings passes; no runtime or test changes.

Assisted-by: OpenAI Codex:model version not exposed
@youknowone
youknowone enabled auto-merge (squash) November 3, 2026 16:37
@youknowone
youknowone merged commit c8991a5 into RustPython:main Nov 3, 2026
28 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