Skip to content

Commit db44b6c

Browse files
Add generic test
1 parent fa84504 commit db44b6c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test-data/unit/check-typeguard.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,19 @@ if E()(x):
754754
reveal_type(x) # N: Revealed type is "builtins.int"
755755
[builtins fixtures/tuple.pyi]
756756

757+
[case testNoCrashOnDunderCallTypeIsTemporaryObjectGeneric]
758+
from typing import Generic, TypeVar
759+
from typing_extensions import TypeIs
760+
T = TypeVar("T")
761+
class E(Generic[T]):
762+
def __init__(self) -> None: ...
763+
def __call__(self, o: object) -> TypeIs[T]:
764+
return True
765+
x = object()
766+
if E[int]()(x):
767+
reveal_type(x) # N: Revealed type is "builtins.int"
768+
[builtins fixtures/tuple.pyi]
769+
757770
[case testTypeGuardRestrictAwaySingleInvariant]
758771
from typing import List
759772
from typing_extensions import TypeGuard

0 commit comments

Comments
 (0)