2Tests checking the version or platform.
5# Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checking
11if sys.version_info >= (3, 8):
14 val1: int = "" # Should not generate an error
Unexpected error
[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
16if sys.version_info >= (3, 8, 0):
19 val2: int = "" # E?: May not generate an error (support for three-element sys.version is optional)
[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
21if sys.version_info < (3, 8):
22 val3: int = "" # Should not generate an error
Unexpected error
[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
24if sys.version_info < (3, 100, 0):
27 val3: int = "" # E?: May not generate an error (support for three-element sys.version is optional)
[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
30if sys.platform == "bogus_platform":
31 val5: int = "" # Should not generate an error
Unexpected error
[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
33if sys.platform != "bogus_platform":
36 val6: int = "" # Should not generate an error
Unexpected error
[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
39if os.name == "bogus_os":
40 val7: int = "" # E?: May not generate an error (support for os.name is optional)
[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
42if os.name != "bogus_platform":
45 val8: int = "" # E?: May not generate an error (support for os.name is optional)
[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`