Skip to content

Commit e2fb448

Browse files
authored
Clean up some Python 2 configuration (#13258)
1 parent 4a4aa9f commit e2fb448

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

mypy/config_parser.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ def parse_version(v: Union[str, float]) -> Tuple[int, int]:
4242
if not m:
4343
raise argparse.ArgumentTypeError(f"Invalid python version '{v}' (expected format: 'x.y')")
4444
major, minor = int(m.group(1)), int(m.group(2))
45-
if major == 2:
46-
if minor != 7:
47-
raise argparse.ArgumentTypeError(f"Python 2.{minor} is not supported (must be 2.7)")
45+
if major == 2 and minor == 7:
46+
pass # Error raised elsewhere
4847
elif major == 3:
4948
if minor < defaults.PYTHON3_VERSION_MIN[1]:
5049
msg = "Python 3.{0} is not supported (must be {1}.{2} or higher)".format(
@@ -57,7 +56,7 @@ def parse_version(v: Union[str, float]) -> Tuple[int, int]:
5756
raise argparse.ArgumentTypeError(msg)
5857
else:
5958
raise argparse.ArgumentTypeError(
60-
f"Python major version '{major}' out of range (must be 2 or 3)"
59+
f"Python major version '{major}' out of range (must be 3)"
6160
)
6261
return major, minor
6362

test-data/unit/cmdline.test

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -604,16 +604,7 @@ pyproject.toml: [mypy]: python_version: Python 3.1 is not supported (must be 3.4
604604
\[mypy]
605605
python_version = 1.0
606606
[out]
607-
mypy.ini: [mypy]: python_version: Python major version '1' out of range (must be 2 or 3)
608-
== Return code: 0
609-
610-
[case testPythonVersionTooOld26]
611-
# cmd: mypy -c pass
612-
[file mypy.ini]
613-
\[mypy]
614-
python_version = 2.6
615-
[out]
616-
mypy.ini: [mypy]: python_version: Python 2.6 is not supported (must be 2.7)
607+
mypy.ini: [mypy]: python_version: Python major version '1' out of range (must be 3)
617608
== Return code: 0
618609

619610
[case testPythonVersionTooOld33]
@@ -625,25 +616,16 @@ python_version = 3.3
625616
mypy.ini: [mypy]: python_version: Python 3.3 is not supported (must be 3.4 or higher)
626617
== Return code: 0
627618

628-
[case testPythonVersionTooNew28]
629-
# cmd: mypy -c pass
630-
[file mypy.ini]
631-
\[mypy]
632-
python_version = 2.8
633-
[out]
634-
mypy.ini: [mypy]: python_version: Python 2.8 is not supported (must be 2.7)
635-
== Return code: 0
636-
637619
[case testPythonVersionTooNew40]
638620
# cmd: mypy -c pass
639621
[file mypy.ini]
640622
\[mypy]
641623
python_version = 4.0
642624
[out]
643-
mypy.ini: [mypy]: python_version: Python major version '4' out of range (must be 2 or 3)
625+
mypy.ini: [mypy]: python_version: Python major version '4' out of range (must be 3)
644626
== Return code: 0
645627

646-
[case testPythonVersionAccepted27]
628+
[case testPythonVersionTooDead27]
647629
# cmd: mypy -c pass
648630
[file mypy.ini]
649631
\[mypy]

0 commit comments

Comments
 (0)