Accept inlay type hint and automatically insert into code #14281
-
I'm using inlay type hints in a gradually typed Python code base. My language server (basedpyright) is doing a great job of inferring types. At the moment, whenever I encounter an inlay hint standing in for a missing type hint, I manually edit the code to add the type hint. I was wondering, does there are already exist some way to accept inlay hints? As in, could I move my caret onto the line containing inlay hints and do something like So far I haven't found anything, but I quickly wanted to check here before submitting a FR. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
beware that for some language servers inserting inlay hints would result in compiler diagnostics. for example rust-analyzer's inlay hints include function parameter names, eg |
Beta Was this translation helpful? Give feedback.
-
This feature should be provided by the language server since it takes language-specific knowledge to know whether the inlay hint is valid code to be inserted. For example with rust-analyzer you can hover over a variable and use a code action ( |
Beta Was this translation helpful? Give feedback.
This feature should be provided by the language server since it takes language-specific knowledge to know whether the inlay hint is valid code to be inserted. For example with rust-analyzer you can hover over a variable and use a code action (
<space>a
) to insert the explicit type