Skip to content

Commit afb06c2

Browse files
committed
Try another micro-optimization
1 parent 5fa8b37 commit afb06c2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mypy/semanal.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6297,6 +6297,8 @@ def lookup(
62976297

62986298
def record_imported_symbol(self, node: SymbolNode) -> None:
62996299
"""If the symbol was not defined in current module, add its module to module_refs."""
6300+
if not node.fullname:
6301+
return
63006302
if isinstance(node, MypyFile):
63016303
fullname = node.fullname
63026304
elif isinstance(node, TypeInfo):
@@ -6307,7 +6309,9 @@ def record_imported_symbol(self, node: SymbolNode) -> None:
63076309
fullname = node.info.module_name
63086310
else:
63096311
fullname = node.fullname.rsplit(".")[0]
6310-
while fullname not in self.modules and "." in fullname:
6312+
if fullname == self.cur_mod_id:
6313+
return
6314+
while "." in fullname and fullname not in self.modules:
63116315
fullname = fullname.rsplit(".")[0]
63126316
if fullname != self.cur_mod_id and fullname not in self.cur_mod_node.module_refs:
63136317
self.cur_mod_node.module_refs.update(split_module_names(fullname))

0 commit comments

Comments
 (0)