@@ -6574,3 +6574,79 @@ class TheClass:
6574
6574
[out]
6575
6575
[out2]
6576
6576
tmp/a.py:3: note: Revealed type is "def (value: builtins.object) -> lib.TheClass.pyenum@6"
6577
+
6578
+ [case testStartUsingTypeGuard]
6579
+ import a
6580
+ [file a.py]
6581
+ from lib import guard
6582
+ from typing import Union
6583
+ from typing_extensions import assert_type
6584
+ x: Union[int, str]
6585
+
6586
+ [file a.py.2]
6587
+ from lib import guard
6588
+ from typing import Union
6589
+ from typing_extensions import assert_type
6590
+ x: Union[int, str]
6591
+ if guard(x):
6592
+ assert_type(x, int)
6593
+ else:
6594
+ assert_type(x, Union[int, str])
6595
+ [file lib.py]
6596
+ from typing_extensions import TypeGuard
6597
+ def guard(x: object) -> TypeGuard[int]:
6598
+ pass
6599
+ [builtins fixtures/tuple.pyi]
6600
+
6601
+ [case testStartUsingTypeIs]
6602
+ import a
6603
+ [file a.py]
6604
+ from lib import guard
6605
+ from typing import Union
6606
+ from typing_extensions import assert_type
6607
+ x: Union[int, str]
6608
+
6609
+ [file a.py.2]
6610
+ from lib import guard
6611
+ from typing import Union
6612
+ from typing_extensions import assert_type
6613
+ x: Union[int, str]
6614
+ if guard(x):
6615
+ assert_type(x, int)
6616
+ else:
6617
+ assert_type(x, str)
6618
+ [file lib.py]
6619
+ from typing_extensions import TypeIs
6620
+ def guard(x: object) -> TypeIs[int]:
6621
+ pass
6622
+ [builtins fixtures/tuple.pyi]
6623
+
6624
+ [case testTypeGuardToTypeIs]
6625
+ import a
6626
+ [file a.py]
6627
+ from lib import guard
6628
+ from typing import Union
6629
+ from typing_extensions import assert_type
6630
+ x: Union[int, str]
6631
+ if guard(x):
6632
+ assert_type(x, int)
6633
+ else:
6634
+ assert_type(x, Union[int, str])
6635
+ [file a.py.2]
6636
+ from lib import guard
6637
+ from typing import Union
6638
+ from typing_extensions import assert_type
6639
+ x: Union[int, str]
6640
+ if guard(x):
6641
+ assert_type(x, int)
6642
+ else:
6643
+ assert_type(x, str)
6644
+ [file lib.py]
6645
+ from typing_extensions import TypeGuard
6646
+ def guard(x: object) -> TypeGuard[int]:
6647
+ pass
6648
+ [file lib.py.2]
6649
+ from typing_extensions import TypeIs
6650
+ def guard(x: object) -> TypeIs[int]:
6651
+ pass
6652
+ [builtins fixtures/tuple.pyi]
0 commit comments