@@ -115,28 +115,33 @@ def g(x: int): ...
115
115
) # type: ignore # E: Unused "type: ignore" comment
116
116
117
117
[case testPEP570ArgTypesMissing]
118
- # flags: --disallow-untyped-defs
118
+ # flags: --python-version 3.8 -- disallow-untyped-defs
119
119
def f(arg, /) -> None: ... # E: Function is missing a type annotation for one or more arguments
120
120
121
121
[case testPEP570ArgTypesBadDefault]
122
+ # flags: --python-version 3.8
122
123
def f(arg: int = "ERROR", /) -> None: ... # E: Incompatible default for argument "arg" (default has type "str", argument has type "int")
123
124
124
125
[case testPEP570ArgTypesDefault]
126
+ # flags: --python-version 3.8
125
127
def f(arg: int = 0, /) -> None:
126
128
reveal_type(arg) # N: Revealed type is "builtins.int"
127
129
128
130
[case testPEP570ArgTypesRequired]
131
+ # flags: --python-version 3.8
129
132
def f(arg: int, /) -> None:
130
133
reveal_type(arg) # N: Revealed type is "builtins.int"
131
134
132
135
[case testPEP570Required]
136
+ # flags: --python-version 3.8
133
137
def f(arg: int, /) -> None: ... # N: "f" defined here
134
138
f(1)
135
139
f("ERROR") # E: Argument 1 to "f" has incompatible type "str"; expected "int"
136
140
f(arg=1) # E: Unexpected keyword argument "arg" for "f"
137
141
f(arg="ERROR") # E: Unexpected keyword argument "arg" for "f"
138
142
139
143
[case testPEP570Default]
144
+ # flags: --python-version 3.8
140
145
def f(arg: int = 0, /) -> None: ... # N: "f" defined here
141
146
f()
142
147
f(1)
@@ -145,6 +150,7 @@ f(arg=1) # E: Unexpected keyword argument "arg" for "f"
145
150
f(arg="ERROR") # E: Unexpected keyword argument "arg" for "f"
146
151
147
152
[case testPEP570Calls]
153
+ # flags: --python-version 3.8 --no-strict-optional
148
154
from typing import Any, Dict
149
155
def f(p, /, p_or_kw, *, kw) -> None: ... # N: "f" defined here
150
156
d = None # type: Dict[Any, Any]
@@ -157,42 +163,49 @@ f(**d) # E: Missing positional argument "p_or_kw" in call to "f"
157
163
[builtins fixtures/dict.pyi]
158
164
159
165
[case testPEP570Signatures1]
166
+ # flags: --python-version 3.8
160
167
def f(p1: bytes, p2: float, /, p_or_kw: int, *, kw: str) -> None:
161
168
reveal_type(p1) # N: Revealed type is "builtins.bytes"
162
169
reveal_type(p2) # N: Revealed type is "builtins.float"
163
170
reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
164
171
reveal_type(kw) # N: Revealed type is "builtins.str"
165
172
166
173
[case testPEP570Signatures2]
174
+ # flags: --python-version 3.8
167
175
def f(p1: bytes, p2: float = 0.0, /, p_or_kw: int = 0, *, kw: str) -> None:
168
176
reveal_type(p1) # N: Revealed type is "builtins.bytes"
169
177
reveal_type(p2) # N: Revealed type is "builtins.float"
170
178
reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
171
179
reveal_type(kw) # N: Revealed type is "builtins.str"
172
180
173
181
[case testPEP570Signatures3]
182
+ # flags: --python-version 3.8
174
183
def f(p1: bytes, p2: float = 0.0, /, *, kw: int) -> None:
175
184
reveal_type(p1) # N: Revealed type is "builtins.bytes"
176
185
reveal_type(p2) # N: Revealed type is "builtins.float"
177
186
reveal_type(kw) # N: Revealed type is "builtins.int"
178
187
179
188
[case testPEP570Signatures4]
189
+ # flags: --python-version 3.8
180
190
def f(p1: bytes, p2: int = 0, /) -> None:
181
191
reveal_type(p1) # N: Revealed type is "builtins.bytes"
182
192
reveal_type(p2) # N: Revealed type is "builtins.int"
183
193
184
194
[case testPEP570Signatures5]
195
+ # flags: --python-version 3.8
185
196
def f(p1: bytes, p2: float, /, p_or_kw: int) -> None:
186
197
reveal_type(p1) # N: Revealed type is "builtins.bytes"
187
198
reveal_type(p2) # N: Revealed type is "builtins.float"
188
199
reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
189
200
190
201
[case testPEP570Signatures6]
202
+ # flags: --python-version 3.8
191
203
def f(p1: bytes, p2: float, /) -> None:
192
204
reveal_type(p1) # N: Revealed type is "builtins.bytes"
193
205
reveal_type(p2) # N: Revealed type is "builtins.float"
194
206
195
207
[case testPEP570Unannotated]
208
+ # flags: --python-version 3.8
196
209
def f(arg, /): ... # N: "f" defined here
197
210
g = lambda arg, /: arg
198
211
def h(arg=0, /): ... # N: "h" defined here
@@ -561,6 +574,7 @@ def foo() -> None:
561
574
[builtins fixtures/dict.pyi]
562
575
563
576
[case testOverloadWithPositionalOnlySelf]
577
+ # flags: --python-version 3.8
564
578
from typing import overload, Optional
565
579
566
580
class Foo:
@@ -585,6 +599,7 @@ class Bar:
585
599
[builtins fixtures/bool.pyi]
586
600
587
601
[case testOverloadPositionalOnlyErrorMessage]
602
+ # flags: --python-version 3.8
588
603
from typing import overload
589
604
590
605
@overload
@@ -595,12 +610,13 @@ def foo(a): ...
595
610
596
611
foo(a=1)
597
612
[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
602
617
603
618
[case testOverloadPositionalOnlyErrorMessageAllTypes]
619
+ # flags: --python-version 3.8
604
620
from typing import overload
605
621
606
622
@overload
@@ -611,12 +627,13 @@ def foo(a, b, *, c): ...
611
627
612
628
foo(a=1)
613
629
[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
618
634
619
635
[case testOverloadPositionalOnlyErrorMessageMultiplePosArgs]
636
+ # flags: --python-version 3.8
620
637
from typing import overload
621
638
622
639
@overload
@@ -627,12 +644,13 @@ def foo(a, b, c, d): ...
627
644
628
645
foo(a=1)
629
646
[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
634
651
635
652
[case testOverloadPositionalOnlyErrorMessageMethod]
653
+ # flags: --python-version 3.8
636
654
from typing import overload
637
655
638
656
class Some:
@@ -646,13 +664,14 @@ class Some:
646
664
647
665
Some().foo(a=1)
648
666
[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
654
672
655
673
[case testOverloadPositionalOnlyErrorMessageClassMethod]
674
+ # flags: --python-version 3.8
656
675
from typing import overload
657
676
658
677
class Some:
@@ -671,13 +690,14 @@ class Some:
671
690
Some.foo(a=1)
672
691
[builtins fixtures/classmethod.pyi]
673
692
[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
679
698
680
699
[case testUnpackWithDuplicateNamePositionalOnly]
700
+ # flags: --python-version 3.8
681
701
from typing_extensions import Unpack, TypedDict
682
702
683
703
class Person(TypedDict):
0 commit comments