basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

Inlay hints for inferred generics

Open KotlinIsland opened this issue 1 year ago • 2 comments

@dataclass
class A[T]:
    t: T
print(A(1))

The inlay should show on the line:

print(A`[int]`(1))

And functions:

def f[T](t: T): ...
f`[int]`(1)  # WARNING: this isn't valid denotation!!!

Not sure how collection literals would look:

print(`[int]`[1, 2, 3])
print(`[int]`{1, 2, 3})
print(`[int]`{1, 2, 3})

Additionally, this is invalid syntax.

KotlinIsland avatar Apr 16 '24 01:04 KotlinIsland

i think they should only appear in instances where it's valid (ie. only on classes, not functions or literals)

DetachHead avatar Apr 16 '24 03:04 DetachHead

hmm, looks like inlay hints for other languages don't follow my made-up rule: https://code.visualstudio.com/docs/typescript/typescript-editing#_inlay-hints

specifically, these inlay hints would not be valid syntax if they were to be converted to real code:

inlay-parameters

so i might change my mind about this, but we need to keep #198 in mind

DetachHead avatar Apr 16 '24 03:04 DetachHead