diff --git a/misc/dump-ast.py b/misc/dump-ast.py index bf59a9a01236..1251f44c2288 100755 --- a/misc/dump-ast.py +++ b/misc/dump-ast.py @@ -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: diff --git a/mypy/defaults.py b/mypy/defaults.py index cd689bf3f9c1..10b15566e68e 100644 --- a/mypy/defaults.py +++ b/mypy/defaults.py @@ -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). diff --git a/mypy/main.py b/mypy/main.py index 85a1eb0765eb..c98fe0ad9736 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -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", diff --git a/mypy/test/helpers.py b/mypy/test/helpers.py index a77cc38c7cb8..cbd623fc9acd 100644 --- a/mypy/test/helpers.py +++ b/mypy/test/helpers.py @@ -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.""" @@ -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")