Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up some Python 2 configuration #13258

Merged
merged 3 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions mypy/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ def parse_version(v: Union[str, float]) -> Tuple[int, int]:
if not m:
raise argparse.ArgumentTypeError(f"Invalid python version '{v}' (expected format: 'x.y')")
major, minor = int(m.group(1)), int(m.group(2))
if major == 2:
if minor != 7:
raise argparse.ArgumentTypeError(f"Python 2.{minor} is not supported (must be 2.7)")
if major == 2 and minor == 7:
pass # Error raised elsewhere
elif major == 3:
if minor < defaults.PYTHON3_VERSION_MIN[1]:
msg = "Python 3.{0} is not supported (must be {1}.{2} or higher)".format(
Expand All @@ -57,7 +56,7 @@ def parse_version(v: Union[str, float]) -> Tuple[int, int]:
raise argparse.ArgumentTypeError(msg)
else:
raise argparse.ArgumentTypeError(
f"Python major version '{major}' out of range (must be 2 or 3)"
f"Python major version '{major}' out of range (must be 3)"
)
return major, minor

Expand Down
24 changes: 3 additions & 21 deletions test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -604,16 +604,7 @@ pyproject.toml: [mypy]: python_version: Python 3.1 is not supported (must be 3.4
\[mypy]
python_version = 1.0
[out]
mypy.ini: [mypy]: python_version: Python major version '1' out of range (must be 2 or 3)
== Return code: 0

[case testPythonVersionTooOld26]
# cmd: mypy -c pass
[file mypy.ini]
\[mypy]
python_version = 2.6
[out]
mypy.ini: [mypy]: python_version: Python 2.6 is not supported (must be 2.7)
mypy.ini: [mypy]: python_version: Python major version '1' out of range (must be 3)
== Return code: 0

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

[case testPythonVersionTooNew28]
# cmd: mypy -c pass
[file mypy.ini]
\[mypy]
python_version = 2.8
[out]
mypy.ini: [mypy]: python_version: Python 2.8 is not supported (must be 2.7)
== Return code: 0

[case testPythonVersionTooNew40]
# cmd: mypy -c pass
[file mypy.ini]
\[mypy]
python_version = 4.0
[out]
mypy.ini: [mypy]: python_version: Python major version '4' out of range (must be 2 or 3)
mypy.ini: [mypy]: python_version: Python major version '4' out of range (must be 3)
== Return code: 0

[case testPythonVersionAccepted27]
[case testPythonVersionTooDead27]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

# cmd: mypy -c pass
[file mypy.ini]
\[mypy]
Expand Down