Skip to content

Commit 93aff8a

Browse files
committed
Try idcluding only module itself
1 parent afb06c2 commit 93aff8a

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

mypy/indirection.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import mypy.types as types
66
from mypy.types import TypeVisitor
7-
from mypy.util import split_module_names
87

98

109
class TypeIndirectionVisitor(TypeVisitor[None]):
@@ -64,10 +63,6 @@ def _visit_type_list(self, typs: list[types.Type]) -> None:
6463
self.seen_types.add(typ)
6564
typ.accept(self)
6665

67-
def _visit_module_name(self, module_name: str) -> None:
68-
if module_name not in self.modules:
69-
self.modules.update(split_module_names(module_name))
70-
7166
def visit_unbound_type(self, t: types.UnboundType) -> None:
7267
self._visit_type_tuple(t.args)
7368

@@ -118,7 +113,7 @@ def visit_instance(self, t: types.Instance) -> None:
118113
# Important optimization: instead of simply recording the definition and
119114
# recursing into bases, record the MRO and only traverse generic bases.
120115
for s in t.type.mro:
121-
self._visit_module_name(s.module_name)
116+
self.modules.add(s.module_name)
122117
for base in s.bases:
123118
if base.args:
124119
self._visit_type_tuple(base.args)
@@ -163,6 +158,6 @@ def visit_type_alias_type(self, t: types.TypeAliasType) -> None:
163158
# Type alias is named, record its definition and continue digging into
164159
# components that constitute semantic meaning of this type: target and args.
165160
if t.alias:
166-
self._visit_module_name(t.alias.module)
161+
self.modules.add(t.alias.module)
167162
self._visit(t.alias.target)
168163
self._visit_type_list(t.args)

mypy/semanal.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,7 @@
305305
)
306306
from mypy.types_utils import is_invalid_recursive_alias, store_argument_type
307307
from mypy.typevars import fill_typevars
308-
from mypy.util import (
309-
correct_relative_import,
310-
is_dunder,
311-
module_prefix,
312-
split_module_names,
313-
unmangle,
314-
unnamed_function,
315-
)
308+
from mypy.util import correct_relative_import, is_dunder, module_prefix, unmangle, unnamed_function
316309
from mypy.visitor import NodeVisitor
317310

318311
T = TypeVar("T")
@@ -6313,8 +6306,8 @@ def record_imported_symbol(self, node: SymbolNode) -> None:
63136306
return
63146307
while "." in fullname and fullname not in self.modules:
63156308
fullname = fullname.rsplit(".")[0]
6316-
if fullname != self.cur_mod_id and fullname not in self.cur_mod_node.module_refs:
6317-
self.cur_mod_node.module_refs.update(split_module_names(fullname))
6309+
if fullname != self.cur_mod_id:
6310+
self.cur_mod_node.module_refs.add(fullname)
63186311

63196312
def _lookup(
63206313
self, name: str, ctx: Context, suppress_errors: bool = False

0 commit comments

Comments
 (0)