2Tests checking the version or platform.
5# Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checking
9from typing import assert_type
11def test(a: int, b: str):
13 if sys.version_info >= (3, 8):
18 assert_type(val1, int)
21 if sys.version_info >= (3, 8, 0):
26 assert_type(val2, int) # E?: May not generate an error (support for three-element sys.version is optional)
28 if sys.version_info < (3, 8):
33 this_raises = val3 # E: `val3` is undefined
[unresolved-reference] Name `val3` used when not defined
34 does_not_raise = val4 # should not error
37 if sys.version_info < (3, 100, 0):
42 assert_type(val5, int) # E?: May not generate an error (support for three-element sys.version is optional)
45 if sys.platform == "bogus_platform":
50 this_raises = val6 # E: `val6` is undefined
[unresolved-reference] Name `val6` used when not defined
51 does_not_raise = val7 # should not error
53 if sys.platform != "bogus_platform":
58 does_not_raise = val8 # should not error
59 this_raises = val9 # E: `val9` is undefined
[unresolved-reference] Name `val9` used when not defined
61 if os.name == "bogus_os":
66 this_raises = val10 # E?: `val10` is undefined, but support for `os.name` is optional
[unresolved-reference] Name `val10` used when not defined
67 does_not_raise = val11 # E? should not error if `os.name` control flow is supported, but might be flagged as possibly undefined otherwise
69 if os.name != "bogus_os":
74 does_not_raise = val12 # E?: should not error if `os.name` control flow is supported, but might be flagged as possibly undefined otherwise
75 this_raises = val13 # E?: `val13` is undefined, but support for `os.name` is optional
[unresolved-reference] Name `val13` used when not defined