Skip to content

Commit 3ee33bd

Browse files
committed
.
1 parent 05f90ef commit 3ee33bd

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

test-data/unit/check-narrowing.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,6 +3168,32 @@ def main(x: Union[B, C]):
31683168
reveal_type(x) # N: Revealed type is "__main__.B | __main__.C"
31693169
[builtins fixtures/isinstance.pyi]
31703170

3171+
[case testTypeEqualsCheckTypeVar]
3172+
# flags: --strict-equality --warn-unreachable
3173+
from typing import TypeVar
3174+
3175+
class A: ...
3176+
class B: ...
3177+
3178+
T = TypeVar("T", A, B)
3179+
3180+
def f1(self, obj: T) -> T:
3181+
if type(obj) == A:
3182+
return A()
3183+
elif type(obj) == B:
3184+
return B()
3185+
raise
3186+
3187+
T_value = TypeVar("T_value", A, B)
3188+
3189+
def f2(self, obj: T_value) -> T_value:
3190+
if type(obj) == A:
3191+
return A()
3192+
elif type(obj) == B:
3193+
return B()
3194+
raise
3195+
[builtins fixtures/primitives.pyi]
3196+
31713197
[case testTypeEqualsCheckUsingDifferentSpecializedTypes]
31723198
# flags: --warn-unreachable
31733199
from collections import defaultdict

0 commit comments

Comments
 (0)