@@ -115,33 +115,28 @@ def g(x: int): ...
115
115
) # type: ignore # E: Unused "type: ignore" comment
116
116
117
117
[case testPEP570ArgTypesMissing]
118
- # flags: --python-version 3.8 -- disallow-untyped-defs
118
+ # flags: --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
123
122
def f(arg: int = "ERROR", /) -> None: ... # E: Incompatible default for argument "arg" (default has type "str", argument has type "int")
124
123
125
124
[case testPEP570ArgTypesDefault]
126
- # flags: --python-version 3.8
127
125
def f(arg: int = 0, /) -> None:
128
126
reveal_type(arg) # N: Revealed type is "builtins.int"
129
127
130
128
[case testPEP570ArgTypesRequired]
131
- # flags: --python-version 3.8
132
129
def f(arg: int, /) -> None:
133
130
reveal_type(arg) # N: Revealed type is "builtins.int"
134
131
135
132
[case testPEP570Required]
136
- # flags: --python-version 3.8
137
133
def f(arg: int, /) -> None: ... # N: "f" defined here
138
134
f(1)
139
135
f("ERROR") # E: Argument 1 to "f" has incompatible type "str"; expected "int"
140
136
f(arg=1) # E: Unexpected keyword argument "arg" for "f"
141
137
f(arg="ERROR") # E: Unexpected keyword argument "arg" for "f"
142
138
143
139
[case testPEP570Default]
144
- # flags: --python-version 3.8
145
140
def f(arg: int = 0, /) -> None: ... # N: "f" defined here
146
141
f()
147
142
f(1)
@@ -150,7 +145,7 @@ f(arg=1) # E: Unexpected keyword argument "arg" for "f"
150
145
f(arg="ERROR") # E: Unexpected keyword argument "arg" for "f"
151
146
152
147
[case testPEP570Calls]
153
- # flags: --python-version 3.8 -- no-strict-optional
148
+ # flags: --no-strict-optional
154
149
from typing import Any, Dict
155
150
def f(p, /, p_or_kw, *, kw) -> None: ... # N: "f" defined here
156
151
d = None # type: Dict[Any, Any]
@@ -163,49 +158,42 @@ f(**d) # E: Missing positional argument "p_or_kw" in call to "f"
163
158
[builtins fixtures/dict.pyi]
164
159
165
160
[case testPEP570Signatures1]
166
- # flags: --python-version 3.8
167
161
def f(p1: bytes, p2: float, /, p_or_kw: int, *, kw: str) -> None:
168
162
reveal_type(p1) # N: Revealed type is "builtins.bytes"
169
163
reveal_type(p2) # N: Revealed type is "builtins.float"
170
164
reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
171
165
reveal_type(kw) # N: Revealed type is "builtins.str"
172
166
173
167
[case testPEP570Signatures2]
174
- # flags: --python-version 3.8
175
168
def f(p1: bytes, p2: float = 0.0, /, p_or_kw: int = 0, *, kw: str) -> None:
176
169
reveal_type(p1) # N: Revealed type is "builtins.bytes"
177
170
reveal_type(p2) # N: Revealed type is "builtins.float"
178
171
reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
179
172
reveal_type(kw) # N: Revealed type is "builtins.str"
180
173
181
174
[case testPEP570Signatures3]
182
- # flags: --python-version 3.8
183
175
def f(p1: bytes, p2: float = 0.0, /, *, kw: int) -> None:
184
176
reveal_type(p1) # N: Revealed type is "builtins.bytes"
185
177
reveal_type(p2) # N: Revealed type is "builtins.float"
186
178
reveal_type(kw) # N: Revealed type is "builtins.int"
187
179
188
180
[case testPEP570Signatures4]
189
- # flags: --python-version 3.8
190
181
def f(p1: bytes, p2: int = 0, /) -> None:
191
182
reveal_type(p1) # N: Revealed type is "builtins.bytes"
192
183
reveal_type(p2) # N: Revealed type is "builtins.int"
193
184
194
185
[case testPEP570Signatures5]
195
- # flags: --python-version 3.8
196
186
def f(p1: bytes, p2: float, /, p_or_kw: int) -> None:
197
187
reveal_type(p1) # N: Revealed type is "builtins.bytes"
198
188
reveal_type(p2) # N: Revealed type is "builtins.float"
199
189
reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
200
190
201
191
[case testPEP570Signatures6]
202
- # flags: --python-version 3.8
203
192
def f(p1: bytes, p2: float, /) -> None:
204
193
reveal_type(p1) # N: Revealed type is "builtins.bytes"
205
194
reveal_type(p2) # N: Revealed type is "builtins.float"
206
195
207
196
[case testPEP570Unannotated]
208
- # flags: --python-version 3.8
209
197
def f(arg, /): ... # N: "f" defined here
210
198
g = lambda arg, /: arg
211
199
def h(arg=0, /): ... # N: "h" defined here
@@ -223,7 +211,6 @@ h(arg=0) # E: Unexpected keyword argument "arg" for "h"
223
211
i(arg=0) # E: Unexpected keyword argument "arg"
224
212
225
213
[case testWalrus]
226
- # flags: --python-version 3.8
227
214
from typing import NamedTuple, Optional, List
228
215
from typing_extensions import Final
229
216
@@ -399,7 +386,6 @@ reveal_type(z2) # E: Name "z2" is not defined # N: Revealed type is "Any"
399
386
[builtins fixtures/isinstancelist.pyi]
400
387
401
388
[case testWalrusConditionalTypeBinder]
402
- # flags: --python-version 3.8
403
389
from typing import Tuple, Union
404
390
from typing_extensions import Literal
405
391
@@ -427,7 +413,6 @@ else:
427
413
[builtins fixtures/list.pyi]
428
414
429
415
[case testWalrusConditionalTypeCheck]
430
- # flags: --python-version 3.8
431
416
from typing import Optional
432
417
433
418
maybe_str: Optional[str]
@@ -443,7 +428,6 @@ reveal_type(maybe_str) # N: Revealed type is "Union[builtins.str, None]"
443
428
[builtins fixtures/bool.pyi]
444
429
445
430
[case testWalrusConditionalTypeCheck2]
446
- # flags: --python-version 3.8
447
431
from typing import Optional
448
432
449
433
maybe_str: Optional[str]
@@ -459,7 +443,6 @@ reveal_type(maybe_str) # N: Revealed type is "Union[builtins.str, None]"
459
443
[builtins fixtures/bool.pyi]
460
444
461
445
[case testWalrusPartialTypes]
462
- # flags: --python-version 3.8
463
446
from typing import List
464
447
465
448
def check_partial_list() -> None:
@@ -476,7 +459,7 @@ def check_partial_list() -> None:
476
459
[builtins fixtures/list.pyi]
477
460
478
461
[case testWalrusAssignmentAndConditionScopeForLiteral]
479
- # flags: --warn-unreachable --python-version 3.8
462
+ # flags: --warn-unreachable
480
463
481
464
if (x := 0):
482
465
reveal_type(x) # E: Statement is unreachable
@@ -486,7 +469,7 @@ else:
486
469
reveal_type(x) # N: Revealed type is "builtins.int"
487
470
488
471
[case testWalrusAssignmentAndConditionScopeForProperty]
489
- # flags: --warn-unreachable --python-version 3.8
472
+ # flags: --warn-unreachable
490
473
491
474
from typing_extensions import Literal
492
475
@@ -514,7 +497,7 @@ reveal_type(y) # N: Revealed type is "Literal[False]"
514
497
[builtins fixtures/property.pyi]
515
498
516
499
[case testWalrusAssignmentAndConditionScopeForFunction]
517
- # flags: --warn-unreachable --python-version 3.8
500
+ # flags: --warn-unreachable
518
501
519
502
from typing_extensions import Literal
520
503
@@ -547,7 +530,6 @@ reveal_type(z) # N: Revealed type is "Literal[False]"
547
530
[builtins fixtures/tuple.pyi]
548
531
549
532
[case testWalrusExpr]
550
- # flags: --python-version 3.8
551
533
def func() -> None:
552
534
foo = Foo()
553
535
if x := foo.x:
@@ -558,7 +540,6 @@ class Foo:
558
540
self.x = 123
559
541
560
542
[case testWalrusTypeGuard]
561
- # flags: --python-version 3.8
562
543
from typing_extensions import TypeGuard
563
544
def is_float(a: object) -> TypeGuard[float]: pass
564
545
def main(a: object) -> None:
@@ -568,22 +549,19 @@ def main(a: object) -> None:
568
549
[builtins fixtures/tuple.pyi]
569
550
570
551
[case testWalrusRedefined]
571
- # flags: --python-version 3.8
572
552
def foo() -> None:
573
553
x = 0
574
554
[x := x + y for y in [1, 2, 3]]
575
555
[builtins fixtures/dict.pyi]
576
556
577
557
[case testWalrusUsedBeforeDef]
578
- # flags: --python-version 3.8
579
558
class C:
580
559
def f(self, c: 'C') -> None: pass
581
560
582
561
(x := C()).f(y) # E: Cannot determine type of "y" # E: Name "y" is used before definition
583
562
(y := C()).f(y)
584
563
585
564
[case testOverloadWithPositionalOnlySelf]
586
- # flags: --python-version 3.8
587
565
from typing import overload, Optional
588
566
589
567
class Foo:
@@ -608,7 +586,6 @@ class Bar:
608
586
[builtins fixtures/bool.pyi]
609
587
610
588
[case testOverloadPositionalOnlyErrorMessage]
611
- # flags: --python-version 3.8
612
589
from typing import overload
613
590
614
591
@overload
@@ -619,13 +596,12 @@ def foo(a): ...
619
596
620
597
foo(a=1)
621
598
[out]
622
- main:10 : error: No overload variant of "foo" matches argument type "int"
623
- main:10 : note: Possible overload variants:
624
- main:10 : note: def foo(int, /) -> Any
625
- main:10 : note: def foo(a: str) -> Any
599
+ main:9 : error: No overload variant of "foo" matches argument type "int"
600
+ main:9 : note: Possible overload variants:
601
+ main:9 : note: def foo(int, /) -> Any
602
+ main:9 : note: def foo(a: str) -> Any
626
603
627
604
[case testOverloadPositionalOnlyErrorMessageAllTypes]
628
- # flags: --python-version 3.8
629
605
from typing import overload
630
606
631
607
@overload
@@ -636,13 +612,12 @@ def foo(a, b, *, c): ...
636
612
637
613
foo(a=1)
638
614
[out]
639
- main:10 : error: No overload variant of "foo" matches argument type "int"
640
- main:10 : note: Possible overload variants:
641
- main:10 : note: def foo(int, /, b: int, *, c: int) -> Any
642
- main:10 : note: def foo(a: str, b: int, *, c: int) -> Any
615
+ main:9 : error: No overload variant of "foo" matches argument type "int"
616
+ main:9 : note: Possible overload variants:
617
+ main:9 : note: def foo(int, /, b: int, *, c: int) -> Any
618
+ main:9 : note: def foo(a: str, b: int, *, c: int) -> Any
643
619
644
620
[case testOverloadPositionalOnlyErrorMessageMultiplePosArgs]
645
- # flags: --python-version 3.8
646
621
from typing import overload
647
622
648
623
@overload
@@ -653,13 +628,12 @@ def foo(a, b, c, d): ...
653
628
654
629
foo(a=1)
655
630
[out]
656
- main:10 : error: No overload variant of "foo" matches argument type "int"
657
- main:10 : note: Possible overload variants:
658
- main:10 : note: def foo(int, int, int, /, d: str) -> Any
659
- main:10 : note: def foo(a: str, b: int, c: int, d: str) -> Any
631
+ main:9 : error: No overload variant of "foo" matches argument type "int"
632
+ main:9 : note: Possible overload variants:
633
+ main:9 : note: def foo(int, int, int, /, d: str) -> Any
634
+ main:9 : note: def foo(a: str, b: int, c: int, d: str) -> Any
660
635
661
636
[case testOverloadPositionalOnlyErrorMessageMethod]
662
- # flags: --python-version 3.8
663
637
from typing import overload
664
638
665
639
class Some:
@@ -673,14 +647,13 @@ class Some:
673
647
674
648
Some().foo(a=1)
675
649
[out]
676
- main:13 : error: No overload variant of "foo" of "Some" matches argument type "int"
677
- main:13 : note: Possible overload variants:
678
- main:13 : note: def foo(self, int, /) -> Any
679
- main:13 : note: def foo(self, float, /) -> Any
680
- main:13 : note: def foo(self, a: str) -> Any
650
+ main:12 : error: No overload variant of "foo" of "Some" matches argument type "int"
651
+ main:12 : note: Possible overload variants:
652
+ main:12 : note: def foo(self, int, /) -> Any
653
+ main:12 : note: def foo(self, float, /) -> Any
654
+ main:12 : note: def foo(self, a: str) -> Any
681
655
682
656
[case testOverloadPositionalOnlyErrorMessageClassMethod]
683
- # flags: --python-version 3.8
684
657
from typing import overload
685
658
686
659
class Some:
@@ -699,14 +672,13 @@ class Some:
699
672
Some.foo(a=1)
700
673
[builtins fixtures/classmethod.pyi]
701
674
[out]
702
- main:17 : error: No overload variant of "foo" of "Some" matches argument type "int"
703
- main:17 : note: Possible overload variants:
704
- main:17 : note: def foo(cls, int, /) -> Any
705
- main:17 : note: def foo(cls, float, /) -> Any
706
- main:17 : note: def foo(cls, a: str) -> Any
675
+ main:16 : error: No overload variant of "foo" of "Some" matches argument type "int"
676
+ main:16 : note: Possible overload variants:
677
+ main:16 : note: def foo(cls, int, /) -> Any
678
+ main:16 : note: def foo(cls, float, /) -> Any
679
+ main:16 : note: def foo(cls, a: str) -> Any
707
680
708
681
[case testUnpackWithDuplicateNamePositionalOnly]
709
- # flags: --python-version 3.8
710
682
from typing_extensions import Unpack, TypedDict
711
683
712
684
class Person(TypedDict):
@@ -717,7 +689,7 @@ def foo(name: str, /, **kwargs: Unpack[Person]) -> None: # Allowed
717
689
[builtins fixtures/dict.pyi]
718
690
719
691
[case testPossiblyUndefinedWithAssignmentExpr]
720
- # flags: --python-version 3.8 -- enable-error-code possibly-undefined
692
+ # flags: --enable-error-code possibly-undefined
721
693
def f1() -> None:
722
694
d = {0: 1}
723
695
if int():
@@ -744,7 +716,6 @@ main:9: note: Revealed type is "builtins.int"
744
716
main:9: note: Revealed type is "builtins.str"
745
717
746
718
[case testTypeGuardWithPositionalOnlyArg]
747
- # flags: --python-version 3.8
748
719
from typing_extensions import TypeGuard
749
720
750
721
def typeguard(x: object, /) -> TypeGuard[int]:
@@ -755,10 +726,9 @@ if typeguard(n):
755
726
reveal_type(n)
756
727
[builtins fixtures/tuple.pyi]
757
728
[out]
758
- main:9 : note: Revealed type is "builtins.int"
729
+ main:8 : note: Revealed type is "builtins.int"
759
730
760
731
[case testTypeGuardKeywordFollowingWalrus]
761
- # flags: --python-version 3.8
762
732
from typing import cast
763
733
from typing_extensions import TypeGuard
764
734
@@ -769,7 +739,7 @@ if typeguard(x=(n := cast(object, "hi"))):
769
739
reveal_type(n)
770
740
[builtins fixtures/tuple.pyi]
771
741
[out]
772
- main:9 : note: Revealed type is "builtins.int"
742
+ main:8 : note: Revealed type is "builtins.int"
773
743
774
744
[case testNoCrashOnAssignmentExprClass]
775
745
class C:
0 commit comments