|
4 | 4 |
|
5 | 5 | import mypy.types as types |
6 | 6 | from mypy.types import TypeVisitor |
7 | | -from mypy.util import split_module_names |
8 | 7 |
|
9 | 8 |
|
10 | 9 | class TypeIndirectionVisitor(TypeVisitor[None]): |
@@ -64,10 +63,6 @@ def _visit_type_list(self, typs: list[types.Type]) -> None: |
64 | 63 | self.seen_types.add(typ) |
65 | 64 | typ.accept(self) |
66 | 65 |
|
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 | | - |
71 | 66 | def visit_unbound_type(self, t: types.UnboundType) -> None: |
72 | 67 | self._visit_type_tuple(t.args) |
73 | 68 |
|
@@ -118,7 +113,7 @@ def visit_instance(self, t: types.Instance) -> None: |
118 | 113 | # Important optimization: instead of simply recording the definition and |
119 | 114 | # recursing into bases, record the MRO and only traverse generic bases. |
120 | 115 | for s in t.type.mro: |
121 | | - self._visit_module_name(s.module_name) |
| 116 | + self.modules.add(s.module_name) |
122 | 117 | for base in s.bases: |
123 | 118 | if base.args: |
124 | 119 | self._visit_type_tuple(base.args) |
@@ -163,6 +158,6 @@ def visit_type_alias_type(self, t: types.TypeAliasType) -> None: |
163 | 158 | # Type alias is named, record its definition and continue digging into |
164 | 159 | # components that constitute semantic meaning of this type: target and args. |
165 | 160 | if t.alias: |
166 | | - self._visit_module_name(t.alias.module) |
| 161 | + self.modules.add(t.alias.module) |
167 | 162 | self._visit(t.alias.target) |
168 | 163 | self._visit_type_list(t.args) |
0 commit comments