Enhancement: Support Top-Down Parameter Name Completion for Lambda and Function Assignments (Contextual Scaffolding) #7993
rob3c
started this conversation in
Enhancement
Replies: 1 comment
-
|
Thanks for the suggestion. Moving to discussion item for up votes. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Currently, Pylance/Pyright acts as a "Bottom-Up" validator. It waits for a function or lambda to be defined and then verifies if it matches a type hint. This results in a "blind" development experience where the developer must guess or manually look up parameter names (e.g., UI coordinates like x, y, w, h) even when the target type is explicitly defined.
The Request
Implement "Top-Down" contextual completion. When a lambda or function is being assigned to a variable with a known Protocol or Callable type, the language server should suggest the parameter names from that type during declaration.
Sample Code
Why this is necessary
Alternatives Considered & Why They Fail
UICallback) rather than expanding the call signature. It provides zero visibility into expected parameter names or types.Final Thoughts
The request so far seems pretty reasonable to me and doable within current language constraints and the understanding Pylance has of the codebase. However, lambdas cannot be multi-line as far as I know. They just seem like the lowest hanging fruit for actually implementing this feature request. However, if you can find a way to surface this information using the "def ..." function definition syntax, that would be amazing!
Thanks in advance for your consideration!
Beta Was this translation helpful? Give feedback.
All reactions