Skip to content

Commit

Permalink
fix incorrect inlay hints for generics where one of the types is a tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Nov 24, 2024
1 parent 02d3a9c commit 6972e90
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class TypeInlayHintsWalker extends ParseTreeWalker {
returnType.priv.typeArgs?.length === returnType.shared.typeParams.length
) {
const printedTypeArgs = returnType.priv.typeArgs.flatMap((typeArg) =>
isClass(typeArg) && typeArg.priv.tupleTypeArgs
isClass(typeArg) && typeArg.priv.tupleTypeArgs && typeArg.priv.isUnpacked
? typeArg.priv.tupleTypeArgs.map((asdf) => this._printType(asdf.type))
: this._printType(typeArg)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@ class Foo:

_ = list([1])

class Foo[T]:
class Bar[T]:
def __init__(self, value: T) -> None:
self.value = value

def foo(self) -> None: ...

_ = Foo(True)
_ = Bar(True)

_ = tuple((1,2,3))

class Bar[U, *T]:
class Baz[U, *T]:
def __init__(self, asdf: U,*value: Unpack[T]) -> None:
pass

_ = Bar([1], 1,2,"")
_ = Baz([1], 1,2,"")

class Baz(Foo[int]):
class Qux(Bar[int]):
@override
def foo(self) -> None:
return super().foo()

qux: list[tuple[int, str]] = list()
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ if (process.platform !== 'win32' || !process.env['CI']) {
position: 442,
value: 'asdf=',
},
{
inlayHintType: 'generic',
position: 581,
value: '[tuple[int, str]]',
},
]);
});
} else {
Expand Down

0 comments on commit 6972e90

Please sign in to comment.