-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: "Add Explicit Type Annotation" code-action #4970
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
inlay hints is close, yes, but its a result of the type checking, not a input. writing the type to the file makes sure that if it ever changes, the typechecker would complain. inferring types is great, but the issue is that a different function entirely might change the return type of this one, which i want to catch. of course, i can just write the type myself, but having a action do it for me is very nice. or maybe this issue is a reflection of me getting spoilt by the Rust LSP, Rust-Analyzer, which has a LOT of these sorts of conveniences. |
@laundmo, as the tooltip in the screenshot indicates, you can double-click an inlay hint to write its annotation into the file. Would that be sufficient, or do you feel a code action would be better? |
oh, i didn't even notice the tooltip. i MUCH prefer a code action because it dowesn't need the mouse at all. |
+1 for having this as a code action in addition to a clickable |
Looked everywhere to find a keyboard shortcut to insert an inlay hint in vscode without using mouse, couldn't find it. Adding a code action to insert it would work for me |
Sometimes, especially when writing libraries, explicitly annotating types which pylance can usually just infer is wanted.
I propose making a code-action show up whenever the cursor is at a place where a type annotation could be inserted (behind a variable name, between a functions closing parentheses and colon) which inserts the type pylance already knows as a explicit annotation.
|
is the cursorbecomes
The text was updated successfully, but these errors were encountered: