Skip to content

Commit 8c0001a

Browse files
pkchilevkivskyi
authored andcommitted
Fix crash when looking up _importlib_modulespec names (#3203)
1 parent dde184f commit 8c0001a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

mypy/fixup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
)
1616
from mypy.visitor import NodeVisitor
1717

18+
from mypy.semanal import rev_module_rename_map
19+
1820

1921
def fixup_module_pass_one(tree: MypyFile, modules: Dict[str, MypyFile],
2022
quick_and_dirty: bool) -> None:
@@ -241,6 +243,7 @@ def lookup_qualified(modules: Dict[str, MypyFile], name: str,
241243

242244
def lookup_qualified_stnode(modules: Dict[str, MypyFile], name: str,
243245
quick_and_dirty: bool) -> Optional[SymbolTableNode]:
246+
name = rev_module_rename_map.get(name, name)
244247
head = name
245248
rest = []
246249
while True:

mypy/semanal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@
120120
'_importlib_modulespec.Loader': 'importlib.abc.Loader'
121121
}
122122

123+
rev_module_rename_map = {v: k for (k, v) in module_rename_map.items()}
124+
123125
# Hard coded type promotions (shared between all Python versions).
124126
# These add extra ad-hoc edges to the subtyping relation. For example,
125127
# int is considered a subtype of float, even though there is no

0 commit comments

Comments
 (0)