From 9d5ea093f0b46bd70aef5b280e0f6cb99c4366f5 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Wed, 26 Apr 2017 21:30:33 -0700 Subject: [PATCH 1/2] Revert PR #3205 and #3235 --- mypy/fixup.py | 5 ----- mypy/semanal.py | 7 ------- 2 files changed, 12 deletions(-) diff --git a/mypy/fixup.py b/mypy/fixup.py index 3d7fae415c1a..0d85feb86ef5 100644 --- a/mypy/fixup.py +++ b/mypy/fixup.py @@ -15,8 +15,6 @@ ) from mypy.visitor import NodeVisitor -from mypy.semanal import rev_module_rename_map - def fixup_module_pass_one(tree: MypyFile, modules: Dict[str, MypyFile], quick_and_dirty: bool) -> None: @@ -243,9 +241,6 @@ def lookup_qualified(modules: Dict[str, MypyFile], name: str, def lookup_qualified_stnode(modules: Dict[str, MypyFile], name: str, quick_and_dirty: bool) -> Optional[SymbolTableNode]: - if '_importlib_modulespec' in modules: - # we are using python 3, so renaming is necessary - name = rev_module_rename_map.get(name, name) head = name rest = [] while True: diff --git a/mypy/semanal.py b/mypy/semanal.py index d390455f8fbc..25e6f30f8c22 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -117,20 +117,13 @@ 'typing.typevar': 'typing.TypeVar', } -# Used for python 3 only # Rename objects placed in _importlib_modulespec due to circular imports -# Safe in python 2 because no one will ask for these keys module_rename_map = { '_importlib_modulespec.ModuleType': 'types.ModuleType', '_importlib_modulespec.ModuleSpec': 'importlib.machinery.ModuleSpec', '_importlib_modulespec.Loader': 'importlib.abc.Loader' } -# Must not be used in python 2 (it will replace correct names with incorrect) -# The check for version is currently made at the point of use -# TODO: consider moving these maps from global scope to somewhere where python version is known -rev_module_rename_map = {v: k for (k, v) in module_rename_map.items()} - # Hard coded type promotions (shared between all Python versions). # These add extra ad-hoc edges to the subtyping relation. For example, # int is considered a subtype of float, even though there is no From 146cdb5d3c010d0c8bc9f1cddb50ea269c5e6e6a Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Wed, 26 Apr 2017 21:42:03 -0700 Subject: [PATCH 2/2] Stop redirecting to _importlib_modulespec --- mypy/semanal.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/mypy/semanal.py b/mypy/semanal.py index 25e6f30f8c22..9ce706d6c90e 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -117,13 +117,6 @@ 'typing.typevar': 'typing.TypeVar', } -# Rename objects placed in _importlib_modulespec due to circular imports -module_rename_map = { - '_importlib_modulespec.ModuleType': 'types.ModuleType', - '_importlib_modulespec.ModuleSpec': 'importlib.machinery.ModuleSpec', - '_importlib_modulespec.Loader': 'importlib.abc.Loader' -} - # Hard coded type promotions (shared between all Python versions). # These add extra ad-hoc edges to the subtyping relation. For example, # int is considered a subtype of float, even though there is no @@ -3332,8 +3325,6 @@ def visit_file(self, file: MypyFile, fnam: str, mod_id: str, options: Options) - for d in defs: d.accept(self) - if isinstance(d, ClassDef): - d.info._fullname = module_rename_map.get(d.info._fullname, d.info._fullname) # Add implicit definition of literals/keywords to builtins, as we # cannot define a variable with them explicitly.