File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
31733199from collections import defaultdict
You can’t perform that action at this time.
0 commit comments