@@ -115,28 +115,33 @@ def g(x: int): ...
115115) # type: ignore # E: Unused "type: ignore" comment
116116
117117[case testPEP570ArgTypesMissing]
118- # flags: --disallow-untyped-defs
118+ # flags: --python-version 3.8 -- disallow-untyped-defs
119119def f(arg, /) -> None: ... # E: Function is missing a type annotation for one or more arguments
120120
121121[case testPEP570ArgTypesBadDefault]
122+ # flags: --python-version 3.8
122123def f(arg: int = "ERROR", /) -> None: ... # E: Incompatible default for argument "arg" (default has type "str", argument has type "int")
123124
124125[case testPEP570ArgTypesDefault]
126+ # flags: --python-version 3.8
125127def f(arg: int = 0, /) -> None:
126128 reveal_type(arg) # N: Revealed type is "builtins.int"
127129
128130[case testPEP570ArgTypesRequired]
131+ # flags: --python-version 3.8
129132def f(arg: int, /) -> None:
130133 reveal_type(arg) # N: Revealed type is "builtins.int"
131134
132135[case testPEP570Required]
136+ # flags: --python-version 3.8
133137def f(arg: int, /) -> None: ... # N: "f" defined here
134138f(1)
135139f("ERROR") # E: Argument 1 to "f" has incompatible type "str"; expected "int"
136140f(arg=1) # E: Unexpected keyword argument "arg" for "f"
137141f(arg="ERROR") # E: Unexpected keyword argument "arg" for "f"
138142
139143[case testPEP570Default]
144+ # flags: --python-version 3.8
140145def f(arg: int = 0, /) -> None: ... # N: "f" defined here
141146f()
142147f(1)
@@ -145,6 +150,7 @@ f(arg=1) # E: Unexpected keyword argument "arg" for "f"
145150f(arg="ERROR") # E: Unexpected keyword argument "arg" for "f"
146151
147152[case testPEP570Calls]
153+ # flags: --python-version 3.8 --no-strict-optional
148154from typing import Any, Dict
149155def f(p, /, p_or_kw, *, kw) -> None: ... # N: "f" defined here
150156d = None # type: Dict[Any, Any]
@@ -157,42 +163,49 @@ f(**d) # E: Missing positional argument "p_or_kw" in call to "f"
157163[builtins fixtures/dict.pyi]
158164
159165[case testPEP570Signatures1]
166+ # flags: --python-version 3.8
160167def f(p1: bytes, p2: float, /, p_or_kw: int, *, kw: str) -> None:
161168 reveal_type(p1) # N: Revealed type is "builtins.bytes"
162169 reveal_type(p2) # N: Revealed type is "builtins.float"
163170 reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
164171 reveal_type(kw) # N: Revealed type is "builtins.str"
165172
166173[case testPEP570Signatures2]
174+ # flags: --python-version 3.8
167175def f(p1: bytes, p2: float = 0.0, /, p_or_kw: int = 0, *, kw: str) -> None:
168176 reveal_type(p1) # N: Revealed type is "builtins.bytes"
169177 reveal_type(p2) # N: Revealed type is "builtins.float"
170178 reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
171179 reveal_type(kw) # N: Revealed type is "builtins.str"
172180
173181[case testPEP570Signatures3]
182+ # flags: --python-version 3.8
174183def f(p1: bytes, p2: float = 0.0, /, *, kw: int) -> None:
175184 reveal_type(p1) # N: Revealed type is "builtins.bytes"
176185 reveal_type(p2) # N: Revealed type is "builtins.float"
177186 reveal_type(kw) # N: Revealed type is "builtins.int"
178187
179188[case testPEP570Signatures4]
189+ # flags: --python-version 3.8
180190def f(p1: bytes, p2: int = 0, /) -> None:
181191 reveal_type(p1) # N: Revealed type is "builtins.bytes"
182192 reveal_type(p2) # N: Revealed type is "builtins.int"
183193
184194[case testPEP570Signatures5]
195+ # flags: --python-version 3.8
185196def f(p1: bytes, p2: float, /, p_or_kw: int) -> None:
186197 reveal_type(p1) # N: Revealed type is "builtins.bytes"
187198 reveal_type(p2) # N: Revealed type is "builtins.float"
188199 reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
189200
190201[case testPEP570Signatures6]
202+ # flags: --python-version 3.8
191203def f(p1: bytes, p2: float, /) -> None:
192204 reveal_type(p1) # N: Revealed type is "builtins.bytes"
193205 reveal_type(p2) # N: Revealed type is "builtins.float"
194206
195207[case testPEP570Unannotated]
208+ # flags: --python-version 3.8
196209def f(arg, /): ... # N: "f" defined here
197210g = lambda arg, /: arg
198211def h(arg=0, /): ... # N: "h" defined here
@@ -561,6 +574,7 @@ def foo() -> None:
561574[builtins fixtures/dict.pyi]
562575
563576[case testOverloadWithPositionalOnlySelf]
577+ # flags: --python-version 3.8
564578from typing import overload, Optional
565579
566580class Foo:
@@ -585,6 +599,7 @@ class Bar:
585599[builtins fixtures/bool.pyi]
586600
587601[case testOverloadPositionalOnlyErrorMessage]
602+ # flags: --python-version 3.8
588603from typing import overload
589604
590605@overload
@@ -595,12 +610,13 @@ def foo(a): ...
595610
596611foo(a=1)
597612[out]
598- main:9 : error: No overload variant of "foo" matches argument type "int"
599- main:9 : note: Possible overload variants:
600- main:9 : note: def foo(int, /) -> Any
601- main:9 : note: def foo(a: str) -> Any
613+ main:10 : error: No overload variant of "foo" matches argument type "int"
614+ main:10 : note: Possible overload variants:
615+ main:10 : note: def foo(int, /) -> Any
616+ main:10 : note: def foo(a: str) -> Any
602617
603618[case testOverloadPositionalOnlyErrorMessageAllTypes]
619+ # flags: --python-version 3.8
604620from typing import overload
605621
606622@overload
@@ -611,12 +627,13 @@ def foo(a, b, *, c): ...
611627
612628foo(a=1)
613629[out]
614- main:9 : error: No overload variant of "foo" matches argument type "int"
615- main:9 : note: Possible overload variants:
616- main:9 : note: def foo(int, /, b: int, *, c: int) -> Any
617- main:9 : note: def foo(a: str, b: int, *, c: int) -> Any
630+ main:10 : error: No overload variant of "foo" matches argument type "int"
631+ main:10 : note: Possible overload variants:
632+ main:10 : note: def foo(int, /, b: int, *, c: int) -> Any
633+ main:10 : note: def foo(a: str, b: int, *, c: int) -> Any
618634
619635[case testOverloadPositionalOnlyErrorMessageMultiplePosArgs]
636+ # flags: --python-version 3.8
620637from typing import overload
621638
622639@overload
@@ -627,12 +644,13 @@ def foo(a, b, c, d): ...
627644
628645foo(a=1)
629646[out]
630- main:9 : error: No overload variant of "foo" matches argument type "int"
631- main:9 : note: Possible overload variants:
632- main:9 : note: def foo(int, int, int, /, d: str) -> Any
633- main:9 : note: def foo(a: str, b: int, c: int, d: str) -> Any
647+ main:10 : error: No overload variant of "foo" matches argument type "int"
648+ main:10 : note: Possible overload variants:
649+ main:10 : note: def foo(int, int, int, /, d: str) -> Any
650+ main:10 : note: def foo(a: str, b: int, c: int, d: str) -> Any
634651
635652[case testOverloadPositionalOnlyErrorMessageMethod]
653+ # flags: --python-version 3.8
636654from typing import overload
637655
638656class Some:
@@ -646,13 +664,14 @@ class Some:
646664
647665Some().foo(a=1)
648666[out]
649- main:12 : error: No overload variant of "foo" of "Some" matches argument type "int"
650- main:12 : note: Possible overload variants:
651- main:12 : note: def foo(self, int, /) -> Any
652- main:12 : note: def foo(self, float, /) -> Any
653- main:12 : note: def foo(self, a: str) -> Any
667+ main:13 : error: No overload variant of "foo" of "Some" matches argument type "int"
668+ main:13 : note: Possible overload variants:
669+ main:13 : note: def foo(self, int, /) -> Any
670+ main:13 : note: def foo(self, float, /) -> Any
671+ main:13 : note: def foo(self, a: str) -> Any
654672
655673[case testOverloadPositionalOnlyErrorMessageClassMethod]
674+ # flags: --python-version 3.8
656675from typing import overload
657676
658677class Some:
@@ -671,13 +690,14 @@ class Some:
671690Some.foo(a=1)
672691[builtins fixtures/classmethod.pyi]
673692[out]
674- main:16 : error: No overload variant of "foo" of "Some" matches argument type "int"
675- main:16 : note: Possible overload variants:
676- main:16 : note: def foo(cls, int, /) -> Any
677- main:16 : note: def foo(cls, float, /) -> Any
678- main:16 : note: def foo(cls, a: str) -> Any
693+ main:17 : error: No overload variant of "foo" of "Some" matches argument type "int"
694+ main:17 : note: Possible overload variants:
695+ main:17 : note: def foo(cls, int, /) -> Any
696+ main:17 : note: def foo(cls, float, /) -> Any
697+ main:17 : note: def foo(cls, a: str) -> Any
679698
680699[case testUnpackWithDuplicateNamePositionalOnly]
700+ # flags: --python-version 3.8
681701from typing_extensions import Unpack, TypedDict
682702
683703class Person(TypedDict):
0 commit comments