Repository navigation
Preserve positional-only and keyword-only parameter bindings - #898
Open
yangfan-yf-yf wants to merge 1 commit into
Open
yangfan-yf-yf wants to merge 1 commit into
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:
|
3 tasks done
This branch has not been deployed
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.
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.