Skip to content

Commit e48a025

Browse files
authored
Remove unnecessary --python-version 3.8 references from tests (#16850)
Remove the `--python-version 3.8` flag where it's used to indicate the min python version requirement. Mypy doesn't support running under Python 3.7 / the tests are only run for 3.8+.
1 parent 9f51057 commit e48a025

File tree

4 files changed

+32
-68
lines changed

4 files changed

+32
-68
lines changed

test-data/unit/check-functools.test

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ Ord() >= 1 # E: Unsupported left operand type for >= ("Ord")
102102
[builtins fixtures/dict.pyi]
103103

104104
[case testCachedProperty]
105-
# flags: --python-version 3.8
106105
from functools import cached_property
107106
class Parent:
108107
@property

test-data/unit/check-parameter-specification.test

+2-6
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ reveal_type(f(n)) # N: Revealed type is "def (builtins.int, builtins.bytes) ->
642642
[builtins fixtures/paramspec.pyi]
643643

644644
[case testParamSpecConcatenateNamedArgs]
645-
# flags: --python-version 3.8 --extra-checks
645+
# flags: --extra-checks
646646
# this is one noticeable deviation from PEP but I believe it is for the better
647647
from typing_extensions import ParamSpec, Concatenate
648648
from typing import Callable, TypeVar
@@ -668,8 +668,6 @@ main:17: error: Incompatible return value type (got "Callable[[Arg(int, 'x'), **
668668
main:17: note: This is likely because "result" has named arguments: "x". Consider marking them positional-only
669669

670670
[case testNonStrictParamSpecConcatenateNamedArgs]
671-
# flags: --python-version 3.8
672-
673671
# this is one noticeable deviation from PEP but I believe it is for the better
674672
from typing_extensions import ParamSpec, Concatenate
675673
from typing import Callable, TypeVar
@@ -710,8 +708,6 @@ reveal_type(n(42)) # N: Revealed type is "None"
710708
[builtins fixtures/paramspec.pyi]
711709

712710
[case testCallablesAsParameters]
713-
# flags: --python-version 3.8
714-
715711
# credits to https://github.com/microsoft/pyright/issues/2705
716712
from typing_extensions import ParamSpec, Concatenate
717713
from typing import Generic, Callable, Any
@@ -729,7 +725,7 @@ reveal_type(abc)
729725
bar(abc)
730726
[builtins fixtures/paramspec.pyi]
731727
[out]
732-
main:16: note: Revealed type is "__main__.Foo[[builtins.int, b: builtins.str]]"
728+
main:14: note: Revealed type is "__main__.Foo[[builtins.int, b: builtins.str]]"
733729

734730
[case testSolveParamSpecWithSelfType]
735731
from typing_extensions import ParamSpec, Concatenate

test-data/unit/check-python38.test

+30-60
Original file line numberDiff line numberDiff line change
@@ -115,33 +115,28 @@ def g(x: int): ...
115115
) # type: ignore # E: Unused "type: ignore" comment
116116

117117
[case testPEP570ArgTypesMissing]
118-
# flags: --python-version 3.8 --disallow-untyped-defs
118+
# flags: --disallow-untyped-defs
119119
def 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
123122
def f(arg: int = "ERROR", /) -> None: ... # E: Incompatible default for argument "arg" (default has type "str", argument has type "int")
124123

125124
[case testPEP570ArgTypesDefault]
126-
# flags: --python-version 3.8
127125
def f(arg: int = 0, /) -> None:
128126
reveal_type(arg) # N: Revealed type is "builtins.int"
129127

130128
[case testPEP570ArgTypesRequired]
131-
# flags: --python-version 3.8
132129
def f(arg: int, /) -> None:
133130
reveal_type(arg) # N: Revealed type is "builtins.int"
134131

135132
[case testPEP570Required]
136-
# flags: --python-version 3.8
137133
def f(arg: int, /) -> None: ... # N: "f" defined here
138134
f(1)
139135
f("ERROR") # E: Argument 1 to "f" has incompatible type "str"; expected "int"
140136
f(arg=1) # E: Unexpected keyword argument "arg" for "f"
141137
f(arg="ERROR") # E: Unexpected keyword argument "arg" for "f"
142138

143139
[case testPEP570Default]
144-
# flags: --python-version 3.8
145140
def f(arg: int = 0, /) -> None: ... # N: "f" defined here
146141
f()
147142
f(1)
@@ -150,7 +145,7 @@ f(arg=1) # E: Unexpected keyword argument "arg" for "f"
150145
f(arg="ERROR") # E: Unexpected keyword argument "arg" for "f"
151146

152147
[case testPEP570Calls]
153-
# flags: --python-version 3.8 --no-strict-optional
148+
# flags: --no-strict-optional
154149
from typing import Any, Dict
155150
def f(p, /, p_or_kw, *, kw) -> None: ... # N: "f" defined here
156151
d = None # type: Dict[Any, Any]
@@ -163,49 +158,42 @@ f(**d) # E: Missing positional argument "p_or_kw" in call to "f"
163158
[builtins fixtures/dict.pyi]
164159

165160
[case testPEP570Signatures1]
166-
# flags: --python-version 3.8
167161
def f(p1: bytes, p2: float, /, p_or_kw: int, *, kw: str) -> None:
168162
reveal_type(p1) # N: Revealed type is "builtins.bytes"
169163
reveal_type(p2) # N: Revealed type is "builtins.float"
170164
reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
171165
reveal_type(kw) # N: Revealed type is "builtins.str"
172166

173167
[case testPEP570Signatures2]
174-
# flags: --python-version 3.8
175168
def f(p1: bytes, p2: float = 0.0, /, p_or_kw: int = 0, *, kw: str) -> None:
176169
reveal_type(p1) # N: Revealed type is "builtins.bytes"
177170
reveal_type(p2) # N: Revealed type is "builtins.float"
178171
reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
179172
reveal_type(kw) # N: Revealed type is "builtins.str"
180173

181174
[case testPEP570Signatures3]
182-
# flags: --python-version 3.8
183175
def f(p1: bytes, p2: float = 0.0, /, *, kw: int) -> None:
184176
reveal_type(p1) # N: Revealed type is "builtins.bytes"
185177
reveal_type(p2) # N: Revealed type is "builtins.float"
186178
reveal_type(kw) # N: Revealed type is "builtins.int"
187179

188180
[case testPEP570Signatures4]
189-
# flags: --python-version 3.8
190181
def f(p1: bytes, p2: int = 0, /) -> None:
191182
reveal_type(p1) # N: Revealed type is "builtins.bytes"
192183
reveal_type(p2) # N: Revealed type is "builtins.int"
193184

194185
[case testPEP570Signatures5]
195-
# flags: --python-version 3.8
196186
def f(p1: bytes, p2: float, /, p_or_kw: int) -> None:
197187
reveal_type(p1) # N: Revealed type is "builtins.bytes"
198188
reveal_type(p2) # N: Revealed type is "builtins.float"
199189
reveal_type(p_or_kw) # N: Revealed type is "builtins.int"
200190

201191
[case testPEP570Signatures6]
202-
# flags: --python-version 3.8
203192
def f(p1: bytes, p2: float, /) -> None:
204193
reveal_type(p1) # N: Revealed type is "builtins.bytes"
205194
reveal_type(p2) # N: Revealed type is "builtins.float"
206195

207196
[case testPEP570Unannotated]
208-
# flags: --python-version 3.8
209197
def f(arg, /): ... # N: "f" defined here
210198
g = lambda arg, /: arg
211199
def h(arg=0, /): ... # N: "h" defined here
@@ -223,7 +211,6 @@ h(arg=0) # E: Unexpected keyword argument "arg" for "h"
223211
i(arg=0) # E: Unexpected keyword argument "arg"
224212

225213
[case testWalrus]
226-
# flags: --python-version 3.8
227214
from typing import NamedTuple, Optional, List
228215
from typing_extensions import Final
229216

@@ -399,7 +386,6 @@ reveal_type(z2) # E: Name "z2" is not defined # N: Revealed type is "Any"
399386
[builtins fixtures/isinstancelist.pyi]
400387

401388
[case testWalrusConditionalTypeBinder]
402-
# flags: --python-version 3.8
403389
from typing import Tuple, Union
404390
from typing_extensions import Literal
405391

@@ -427,7 +413,6 @@ else:
427413
[builtins fixtures/list.pyi]
428414

429415
[case testWalrusConditionalTypeCheck]
430-
# flags: --python-version 3.8
431416
from typing import Optional
432417

433418
maybe_str: Optional[str]
@@ -443,7 +428,6 @@ reveal_type(maybe_str) # N: Revealed type is "Union[builtins.str, None]"
443428
[builtins fixtures/bool.pyi]
444429

445430
[case testWalrusConditionalTypeCheck2]
446-
# flags: --python-version 3.8
447431
from typing import Optional
448432

449433
maybe_str: Optional[str]
@@ -459,7 +443,6 @@ reveal_type(maybe_str) # N: Revealed type is "Union[builtins.str, None]"
459443
[builtins fixtures/bool.pyi]
460444

461445
[case testWalrusPartialTypes]
462-
# flags: --python-version 3.8
463446
from typing import List
464447

465448
def check_partial_list() -> None:
@@ -476,7 +459,7 @@ def check_partial_list() -> None:
476459
[builtins fixtures/list.pyi]
477460

478461
[case testWalrusAssignmentAndConditionScopeForLiteral]
479-
# flags: --warn-unreachable --python-version 3.8
462+
# flags: --warn-unreachable
480463

481464
if (x := 0):
482465
reveal_type(x) # E: Statement is unreachable
@@ -486,7 +469,7 @@ else:
486469
reveal_type(x) # N: Revealed type is "builtins.int"
487470

488471
[case testWalrusAssignmentAndConditionScopeForProperty]
489-
# flags: --warn-unreachable --python-version 3.8
472+
# flags: --warn-unreachable
490473

491474
from typing_extensions import Literal
492475

@@ -514,7 +497,7 @@ reveal_type(y) # N: Revealed type is "Literal[False]"
514497
[builtins fixtures/property.pyi]
515498

516499
[case testWalrusAssignmentAndConditionScopeForFunction]
517-
# flags: --warn-unreachable --python-version 3.8
500+
# flags: --warn-unreachable
518501

519502
from typing_extensions import Literal
520503

@@ -547,7 +530,6 @@ reveal_type(z) # N: Revealed type is "Literal[False]"
547530
[builtins fixtures/tuple.pyi]
548531

549532
[case testWalrusExpr]
550-
# flags: --python-version 3.8
551533
def func() -> None:
552534
foo = Foo()
553535
if x := foo.x:
@@ -558,7 +540,6 @@ class Foo:
558540
self.x = 123
559541

560542
[case testWalrusTypeGuard]
561-
# flags: --python-version 3.8
562543
from typing_extensions import TypeGuard
563544
def is_float(a: object) -> TypeGuard[float]: pass
564545
def main(a: object) -> None:
@@ -568,22 +549,19 @@ def main(a: object) -> None:
568549
[builtins fixtures/tuple.pyi]
569550

570551
[case testWalrusRedefined]
571-
# flags: --python-version 3.8
572552
def foo() -> None:
573553
x = 0
574554
[x := x + y for y in [1, 2, 3]]
575555
[builtins fixtures/dict.pyi]
576556

577557
[case testWalrusUsedBeforeDef]
578-
# flags: --python-version 3.8
579558
class C:
580559
def f(self, c: 'C') -> None: pass
581560

582561
(x := C()).f(y) # E: Cannot determine type of "y" # E: Name "y" is used before definition
583562
(y := C()).f(y)
584563

585564
[case testOverloadWithPositionalOnlySelf]
586-
# flags: --python-version 3.8
587565
from typing import overload, Optional
588566

589567
class Foo:
@@ -608,7 +586,6 @@ class Bar:
608586
[builtins fixtures/bool.pyi]
609587

610588
[case testOverloadPositionalOnlyErrorMessage]
611-
# flags: --python-version 3.8
612589
from typing import overload
613590

614591
@overload
@@ -619,13 +596,12 @@ def foo(a): ...
619596

620597
foo(a=1)
621598
[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
626603

627604
[case testOverloadPositionalOnlyErrorMessageAllTypes]
628-
# flags: --python-version 3.8
629605
from typing import overload
630606

631607
@overload
@@ -636,13 +612,12 @@ def foo(a, b, *, c): ...
636612

637613
foo(a=1)
638614
[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
643619

644620
[case testOverloadPositionalOnlyErrorMessageMultiplePosArgs]
645-
# flags: --python-version 3.8
646621
from typing import overload
647622

648623
@overload
@@ -653,13 +628,12 @@ def foo(a, b, c, d): ...
653628

654629
foo(a=1)
655630
[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
660635

661636
[case testOverloadPositionalOnlyErrorMessageMethod]
662-
# flags: --python-version 3.8
663637
from typing import overload
664638

665639
class Some:
@@ -673,14 +647,13 @@ class Some:
673647

674648
Some().foo(a=1)
675649
[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
681655

682656
[case testOverloadPositionalOnlyErrorMessageClassMethod]
683-
# flags: --python-version 3.8
684657
from typing import overload
685658

686659
class Some:
@@ -699,14 +672,13 @@ class Some:
699672
Some.foo(a=1)
700673
[builtins fixtures/classmethod.pyi]
701674
[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
707680

708681
[case testUnpackWithDuplicateNamePositionalOnly]
709-
# flags: --python-version 3.8
710682
from typing_extensions import Unpack, TypedDict
711683

712684
class Person(TypedDict):
@@ -717,7 +689,7 @@ def foo(name: str, /, **kwargs: Unpack[Person]) -> None: # Allowed
717689
[builtins fixtures/dict.pyi]
718690

719691
[case testPossiblyUndefinedWithAssignmentExpr]
720-
# flags: --python-version 3.8 --enable-error-code possibly-undefined
692+
# flags: --enable-error-code possibly-undefined
721693
def f1() -> None:
722694
d = {0: 1}
723695
if int():
@@ -744,7 +716,6 @@ main:9: note: Revealed type is "builtins.int"
744716
main:9: note: Revealed type is "builtins.str"
745717

746718
[case testTypeGuardWithPositionalOnlyArg]
747-
# flags: --python-version 3.8
748719
from typing_extensions import TypeGuard
749720

750721
def typeguard(x: object, /) -> TypeGuard[int]:
@@ -755,10 +726,9 @@ if typeguard(n):
755726
reveal_type(n)
756727
[builtins fixtures/tuple.pyi]
757728
[out]
758-
main:9: note: Revealed type is "builtins.int"
729+
main:8: note: Revealed type is "builtins.int"
759730

760731
[case testTypeGuardKeywordFollowingWalrus]
761-
# flags: --python-version 3.8
762732
from typing import cast
763733
from typing_extensions import TypeGuard
764734

@@ -769,7 +739,7 @@ if typeguard(x=(n := cast(object, "hi"))):
769739
reveal_type(n)
770740
[builtins fixtures/tuple.pyi]
771741
[out]
772-
main:9: note: Revealed type is "builtins.int"
742+
main:8: note: Revealed type is "builtins.int"
773743

774744
[case testNoCrashOnAssignmentExprClass]
775745
class C:

test-data/unit/check-typeddict.test

-1
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,6 @@ reveal_type(p) # N: Revealed type is "TypedDict('__main__.Point', {'x': builtin
17641764
[builtins fixtures/dict.pyi]
17651765

17661766
[case testCanCreateTypedDictWithTypingProper]
1767-
# flags: --python-version 3.8
17681767
from typing import TypedDict
17691768

17701769
class Point(TypedDict):

0 commit comments

Comments
 (0)