From 70a58207c0dbd3c1915765f148f706db9eb1b2b6 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Thu, 13 Sep 2018 17:25:46 +0100 Subject: [PATCH 1/4] Revert "Add some workarounds to simplify bootstrap (#5614)" This reverts commit 4a574c219c1ce876004190331b8b64d741e38dd1. From 33b74f86bd01c893cbc27b9224d3bd9605910842 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Thu, 13 Sep 2018 17:25:46 +0100 Subject: [PATCH 2/4] Revert "Sync typeshed (#5584)" This reverts commit fe0f9333f2722989437dccc12810ea0adcb72a05. From e5971a2c761a19b1186bac9d1e8d50de6a942f82 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Thu, 13 Sep 2018 17:25:46 +0100 Subject: [PATCH 3/4] Revert "Fix logical fine-grained dependencies for __init__ (#5606)" This reverts commit 28b5423c81cb5097395b25c845e6679b32098437. From babb1dcab8f1d5bab5a97c50b1785e69677685e5 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Thu, 13 Sep 2018 17:25:46 +0100 Subject: [PATCH 4/4] Revert "Update "-2" argument to match "--python-version" (#5578)" This reverts commit 9b9e7e1674fa814571af41f7f378b63d1de546ff. --- mypy/main.py | 22 +++++++++------------- mypy/test/testargs.py | 14 -------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index 5f0abd4db6f06..849ba56421dd4 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -284,31 +284,27 @@ def infer_python_version_and_executable(options: Options, This function mutates options based on special_opts to infer the correct Python version and executable to use. """ - # Check Options in case python_version is set in a config file, but prefer command - # line arguments. - python_version = special_opts.python_version or options.python_version - # Infer Python version and/or executable if one is not given # TODO: (ethanhs) Look at folding these checks and the site packages subprocess calls into # one subprocess call for speed. - if special_opts.python_executable is not None and python_version is not None: + if special_opts.python_executable is not None and special_opts.python_version is not None: py_exe_ver = _python_version_from_executable(special_opts.python_executable) - if py_exe_ver != python_version: + if py_exe_ver != special_opts.python_version: raise PythonExecutableInferenceError( 'Python version {} did not match executable {}, got version {}.'.format( - python_version, special_opts.python_executable, py_exe_ver + special_opts.python_version, special_opts.python_executable, py_exe_ver )) else: - options.python_version = python_version + options.python_version = special_opts.python_version options.python_executable = special_opts.python_executable - elif special_opts.python_executable is None and python_version is not None: - options.python_version = python_version + elif special_opts.python_executable is None and special_opts.python_version is not None: + options.python_version = special_opts.python_version py_exe = None if not special_opts.no_executable: - py_exe = _python_executable_from_version(python_version) + py_exe = _python_executable_from_version(special_opts.python_version) options.python_executable = py_exe - elif python_version is None and special_opts.python_executable is not None: + elif special_opts.python_version is None and special_opts.python_executable is not None: options.python_version = _python_version_from_executable( special_opts.python_executable) options.python_executable = special_opts.python_executable @@ -465,7 +461,7 @@ def add_invertible_flag(flag: str, 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', + '-2', '--py2', dest='python_version', action='store_const', const=defaults.PYTHON2_VERSION, help="Use Python 2 mode (same as --python-version 2.7)") platform_group.add_argument( diff --git a/mypy/test/testargs.py b/mypy/test/testargs.py index 175e3e46c3006..bccbafaf4c8bf 100644 --- a/mypy/test/testargs.py +++ b/mypy/test/testargs.py @@ -60,20 +60,6 @@ def test_executable_inference(self) -> None: assert str(e.value) == 'Python version (2, 10) did not match executable {}, got' \ ' version {}.'.format(sys.executable, sys.version_info[:2]) - # If a configuration file specifies python_version, it will be set on options. - # Use that to figure out how to determine a value for python_executable, when - # special_opts.python_version is None. - special_opts = argparse.Namespace() - special_opts.python_executable = None - special_opts.python_version = None - special_opts.no_executable = None - options = Options() - options.python_executable = None - options.python_version = sys.version_info[:2] - infer_python_version_and_executable(options, special_opts) - assert options.python_version == sys.version_info[:2] - assert options.python_executable == sys.executable - # test that --no-site-packages will disable executable inference matching_version = base + ['--python-version={}'.format(sys_ver_str), '--no-site-packages']