Open KotlinIsland opened 5 months ago
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
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
Recently I tested the case once doesn't work and it worked now (Pylance v2024.7.1).
Auto-import from typing is even done.
imo inlay hints should always be valid code, so they should always allow double-clicking to insert them
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 Literal
s are sometimes not shown.
oops, in my example i had it the wrong way around. it's the Callable
inlay hint that doesn't work:
def f(a: int, /) -> str: ...
x = f # doesn't work
foo = "" # works
related: #199
maybe Callable
inlay hints are considered complex by pylance that should be assigned to a type alias?
maybe
Callable
inlay hints are considered complex by pylance that should be assigned to a type alias?
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
Before
backticks represent inlay hints
After