Skip to content

Commit d601265

Browse files
two of three tests for match statements disobeying py version guards a la python#19892
later you can figure out if you want these
1 parent 4301be1 commit d601265

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

‎test-data/unit/check-unreachable-code.test‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,40 @@ assert sys.platform == 'lol'
737737
reveal_type('') # No error here :-)
738738
[builtins fixtures/ops.pyi]
739739

740+
[case testUnreachableAfterToplevelAssertFlaggy]
741+
# flags: --python-version=3.9 --show-error-codes
742+
# This test may false negative succeed if you are actually running python 3.9
743+
import sys
744+
reveal_type(0) # N: Revealed type is "Literal[0]?"
745+
x: int | tuple[int] # E: X | Y syntax for unions requires Python 3.10 [syntax]
746+
"a"+1 # E: Unsupported operand types for + ("str" and "int") [operator]
747+
assert sys.version_info > (3,9)
748+
match point:
749+
case (0, 0):
750+
print("Origin")
751+
case _:
752+
raise ValueError("Not a point")
753+
reveal_type('') # No error here :-)
754+
x: int | tuple[int] # a little 3.10 syntax to check
755+
[builtins fixtures/ops.pyi]
756+
757+
[case testUnreachableAfterToplevelAssertConfigy]
758+
# This test may false negative succeed if you are act>
759+
# flags: --config-file=tmp/foo.ini --show-error-codes
760+
import sys
761+
reveal_type(0) # N: Revealed type is "Literal[0]?"
762+
x: int | tuple[int] # E: X | Y syntax for unions requires Python 3.10 [syntax]
763+
"a"+1 # E: Unsupported operand types for + ("str" and "int") [operator]
764+
assert sys.version_info > (3,9)
765+
reveal_type('') # No error here :-)
766+
x: int | tuple[int] # a little 3.10 syntax to check
767+
768+
[file foo.ini]
769+
\[mypy]
770+
python_version=3.9
771+
772+
[builtins fixtures/ops.pyi]
773+
740774
[case testUnreachableAfterToplevelAssert2]
741775
import sys
742776
reveal_type(0) # N: Revealed type is "Literal[0]?"

0 commit comments

Comments
 (0)