|
118 | 118 | MypyFile, |
119 | 119 | OverloadedFuncDef, |
120 | 120 | SymbolTable, |
121 | | - TypeInfo, |
122 | 121 | ) |
123 | 122 | from mypy.options import OPTIONS_AFFECTING_CACHE_NO_PLATFORM |
124 | 123 | from mypy.partially_defined import PossiblyUndefinedVariableVisitor |
@@ -3480,20 +3479,21 @@ def finish_passes(self) -> None: |
3480 | 3479 | if options.export_types: |
3481 | 3480 | manager.all_types.update(self.type_map()) |
3482 | 3481 |
|
3483 | | - # Possible sources of indirect dependencies: |
3484 | | - # * Symbols not directly imported in this module but accessed via an attribute |
3485 | | - # or via a re-export (vast majority of these recorded in semantic analysis). |
3486 | | - # * For each expression type we need to record definitions of type components |
3487 | | - # since "meaning" of the type may be updated when definitions are updated. |
3488 | | - # * For mypyc-compiled modules only: modules defining MRO ancestors of |
3489 | | - # classes defined here, since the generated C embeds each ancestor's |
3490 | | - # method/attribute layout. |
3491 | | - indirect_refs = self.tree.module_refs | self.type_checker().module_refs |
3492 | | - if self.options.mypyc: |
3493 | | - indirect_refs |= self.compiled_class_ancestor_refs() |
3494 | 3482 | # We should always patch indirect dependencies, even in full (non-incremental) builds, |
3495 | 3483 | # because the cache still may be written, and it must be correct. |
3496 | | - self.patch_indirect_dependencies(indirect_refs, set(self.type_map().values())) |
| 3484 | + self.patch_indirect_dependencies( |
| 3485 | + # Three possible sources of indirect dependencies: |
| 3486 | + # * Symbols not directly imported in this module but accessed via an attribute |
| 3487 | + # or via a re-export (vast majority of these recorded in semantic analysis). |
| 3488 | + # * For each expression type we need to record definitions of type components |
| 3489 | + # since "meaning" of the type may be updated when definitions are updated. |
| 3490 | + # * Additional dependencies reported by plugins (e.g. mypyc, see |
| 3491 | + # MypycPlugin.get_additional_indirect_deps). |
| 3492 | + self.tree.module_refs |
| 3493 | + | self.type_checker().module_refs |
| 3494 | + | manager.plugin.get_additional_indirect_deps(self.tree), |
| 3495 | + set(self.type_map().values()), |
| 3496 | + ) |
3497 | 3497 |
|
3498 | 3498 | if self.options.dump_inference_stats: |
3499 | 3499 | dump_type_stats( |
@@ -3535,27 +3535,6 @@ def patch_indirect_dependencies(self, module_refs: set[str], types: set[Type]) - |
3535 | 3535 | self.add_dependency(dep) |
3536 | 3536 | self.priorities[dep] = PRI_INDIRECT |
3537 | 3537 |
|
3538 | | - def compiled_class_ancestor_refs(self) -> set[str]: |
3539 | | - """Modules defining MRO ancestors of classes defined in this module. |
3540 | | -
|
3541 | | - Only used for mypyc-compiled modules: the generated C for a class |
3542 | | - (vtable arrays, getter/setter tables, object struct) references |
3543 | | - every inherited method/attribute of every ancestor, including |
3544 | | - ancestors defined in modules this module does not import directly. |
3545 | | - Recording them as indirect dependencies makes an ancestor's |
3546 | | - interface change re-trigger type checking (and hence C regeneration) |
3547 | | - of this module. Only top-level classes are scanned: mypyc rejects |
3548 | | - nested class definitions. |
3549 | | - """ |
3550 | | - assert self.tree is not None |
3551 | | - mods: set[str] = set() |
3552 | | - for sym in self.tree.names.values(): |
3553 | | - node = sym.node |
3554 | | - if isinstance(node, TypeInfo) and node.module_name == self.id: |
3555 | | - for ancestor in node.mro[1:]: |
3556 | | - mods.add(ancestor.module_name) |
3557 | | - return mods |
3558 | | - |
3559 | 3538 | def compute_fine_grained_deps(self) -> dict[str, set[str]]: |
3560 | 3539 | assert self.tree is not None |
3561 | 3540 | if self.id in ("builtins", "typing", "types", "sys", "_typeshed"): |
|
0 commit comments