Repository navigation
Preserve positional-only and keyword-only parameter bindings - #898
yangfan-yf-yf wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #898 +/- ##
==========================================
+ Coverage 95.34% 95.47% +0.12%
==========================================
Files 134 136 +2
Lines 26762 27667 +905
==========================================
+ Hits 25516 26414 +898
- Misses 1246 1253 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Independently arrived at the same parameter-binding fixes from a different repro; after diffing against this PR we found nothing functional on our side that #898 does not already cover, so we are adopting #898 as-is. We did port three edge-case parametrizations our repro had that the current suite here does not: a signature with positional-only plus keyword-only but no |
I found that positional-only and keyword-only parameters can resolve to an outer assignment instead of their own binding. Inlining
target = 42abovedef func(*, target): return targetgenerates the invalid declarationdef func(*, 42). Inlining only the body reference leaves valid code that returns42instead of theintpassed byfunc(target=int). Rename and argument inference also lose the parameter identity or use the wrong argument slot.I now give each parameter a stable binding slot, distinguish positional and keyword matching, and evaluate defaults in the enclosing scope. The ordinary slots are positional-only, positional-or-keyword, and keyword-only parameters; variadic object slots follow them. A keyword with the same name as a positional-only parameter goes to
**kwargswithout replacing the positional slot. Unknown unpacking and unknown supplied values do not invent default bindings.I also align static analysis, dynamic call records, method receivers, and callable-object receivers with that layout. A receiver is inserted once: static methods receive none, class methods retain the actual dispatch class, and variadic receivers do not occupy keyword-only slots. Versioned, persistable call scopes isolate changed layouts and receiver rules from old records, including fallback reads; ordinary plain-function and per-name records retain their existing scopes. Static-method parameter attributes are kept separate from the containing class, including actual builtin decorator aliases.
Read-only completion and calltips use the parameter metadata while preserving ordinary signature display. Signature-writing refactorings reject unsupported positional-only or keyword-only rewrites before generating changes. Existing positional-only Inline Method behavior is preserved; keyword-only Inline Method remains unsupported. This change covers parameter bindings and defaults; general annotation-expression scope and deferred-evaluation inlining remain separate boundaries.
Validation:
git diff --checkpasses. Product, test, and documentation hashes are unchanged across the final runs and checks.