8000 Remove `--py2` CLI flags by sobolevn · Pull Request #13270 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Remove --py2 CLI flags #13270

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

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 1 addition & 5 deletions misc/dump-ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ def main() -> None:
parser = argparse.ArgumentParser(
description="Parse source files and print the abstract syntax tree (AST)."
)
parser.add_argument("--py2", action="store_true", help="parse FILEs as Python 2")
parser.add_argument("--quiet", action="store_true", help="do not print AST")
parser.add_argument("FILE", nargs="*", help="files to parse")
args = parser.parse_args()

if args.py2:
pyversion = defaults.PYTHON2_VERSION
else:
pyversion = defaults.PYTHON3_VERSION
pyversion = defaults.PYTHON3_VERSION

status = 0
for fname in args.FILE:
Expand Down
2 changes: 0 additions & 2 deletions mypy/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from typing_extensions import Final

PYTHON2_VERSION: Final = (2, 7)

# Earliest fully supported Python 3.x version. Used as the default Python
# version in tests. Mypy wheels should be built starting with this version,
# and CI tests should be run on this version (and later versions).
Expand Down
8 changes: 0 additions & 8 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,6 @@ def add_invertible_flag(
help="Type check code assuming it will be running on Python x.y",
dest="special-opts:python_version",
)
platform_group.add_argument(
"-2",
"--py2",
dest="special-opts:python_version",
action="store_const",
const=defaults.PYTHON2_VERSION,
help="Use Python 2 mode (same as --python-version 2.7)",
)
platform_group.add_argument(
"--platform",
action="store",
Expand Down
12 changes: 2 additions & 10 deletions mypy/test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,6 @@ def testfile_pyversion(path: str) -> Tuple[int, int]:
return defaults.PYTHON3_VERSION


def testcase_pyversion(path: str, testcase_name: str) -> Tuple[int, int]:
if testcase_name.endswith("python2"):
raise ValueError(testcase_name)
return defaults.PYTHON2_VERSION
else:
return testfile_pyversion(path)


def normalize_error_messages(messages: List[str]) -> List[str]:
"""Translate an array of error messages to use / as path separator."""

Expand Down Expand Up @@ -383,8 +375,8 @@ def parse_options(
options.error_summary = False

# Allow custom python version to override testcase_pyversion.
if all(flag.split("=")[0] not in ["--python-version", "-2", "--py2"] for flag in flag_list):
options.python_version = testcase_pyversion(testcase.file, testcase.name)
if all(flag.split("=")[0] != "--python-version" for flag in flag_list):
options.python_version = testfile_pyversion(testcase.file)

if testcase.config.getoption("--mypy-verbose"):
options.verbosity = testcase.config.getoption("--mypy-verbose")
Expand Down
0