Title: Support Python None defaults in object argument declarations by youknowone · Pull Request #9557 · RustPython/RustPython · GitHub
Open Graph Title: Support Python None defaults in object argument declarations by youknowone · Pull Request #9557 · RustPython/RustPython
X Title: Support Python None defaults in object argument declarations by youknowone · Pull Request #9557 · RustPython/RustPython
Description: 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. Preserve existing Option, OptionalArg, and OptionalOption default expressions and omission semantics. This does not reinterpret None as OptionalArg::Missing or remove explicit Clinic display-default overrides. Construct the default only on omission. Supplied-value conversion is unchanged. PyObjectRef uses the singleton without allocating another Python object or invoking user callbacks. Preserve converter validation for typed references: a PyStrRef with 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. Document the behavior and add three pure token/metadata tests covering lazy placement, typed None metadata, wrapper exclusions, parentheses, existing literals, and typed-reference conversion. No Python objects are constructed by these tests. 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.
Open Graph Description: 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 p...
X Description: 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 p...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9557
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f059d13e-e862-9aa5-0345-10343153e30f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CA84:2E7EBB:3E07C18:4E83350:6B020381 |
| html-safe-nonce | e35df5621101e2c899c7367108b5adca39da6b773e6bc2d1afaca3a807652725 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTg0OjJFN0VCQjozRTA3QzE4OjRFODMzNTA6NkIwMjAzODEiLCJ2aXNpdG9yX2lkIjoiNzcxNDg3NjQxOTMwOTk2MjExMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c88545aede0718b8941b2058c724db8e88742db2c8f20f51328a81609bada9e3 |
| hovercard-subject-tag | pull_request:5130100649 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9557/files |
| twitter:image | https://avatars.githubusercontent.com/u/69878?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/69878?s=400&v=4 |
| og:image:alt | 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 p... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width