-
Notifications
You must be signed in to change notification settings - Fork 19
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
code action/double click to transition inlay hints to real life #198
Comments
|
something i noticed about pylance's implementation of this feature is that it doesn't work on all inlay hints for some reason. eg: def f(a: int, /) -> str: ...
x = f # works
foo = "" # doesn't work imo inlay hints should always be valid code, so they should always allow double-clicking to insert them |
Recently I tested the case once doesn't work and it worked now (Pylance v2024.7.1). Auto-import from typing is even done.
Actually there are also inlay hints which are not valid code, e.g. a, b = "foo", int() # `a` is shown nothing while `b` is shown as `int` in inlay hints.
c = 42 # `c` is shown nothing in inlay hints. hovering mouse cursor to see the type. of course they cannot be inserted. Another thing we can notice is that some not-quite-useful |
oops, in my example i had it the wrong way around. it's the def f(a: int, /) -> str: ...
x = f # doesn't work
foo = "" # works related: #199 |
maybe |
Such a based idea: def f(a=1, /, *, b=False):
return 1
a = f After transition operation: class F(Protocol): # maybe "A"?
def __call__(self, a: int = ..., /, *, b: bool = ...) -> int: ...
a: F = f |
I personally use inlay for maximum information possible, so I'd rather just max info in all situations (I've never used the feature to bring inlay hints into real life / it wouldn't matter to me personally inlay hints aren't valid syntax) Could be a config option though, to disable invalid inlay hints; maybe there's an option for the LSP to throw an error dialog if you try an action but it fails, e.g. for trying to bring invalid inlay hints to real life. If there are two options that provide the same information, but one was valid and the other was invalid, yeah prefer the valid. It would also make more sense. -> Just my thoughts, not saying that's the avg thought or anything. |
Interesting potential edge cases - It's also keyword arguments that appear but aren't actually keyword. E.g., Inlay hints currently don't use namespaces.
-- |
Before
backticks represent inlay hints
After
The text was updated successfully, but these errors were encountered: