| 47 | |
| 48 | |
| 49 | class NodeFixer(NodeVisitor[None]): |
| 50 | current_info: TypeInfo | None = None |
| 51 | |
| 52 | def __init__(self, modules: dict[str, MypyFile], allow_missing: bool) -> None: |
| 53 | self.modules = modules |
| 54 | # N.B: we do an allow_missing fixup when fixing up a fine-grained |
| 55 | # incremental cache load (since there may be cross-refs into deleted |
| 56 | # modules) |
| 57 | self.allow_missing = allow_missing |
| 58 | self.type_fixer = TypeFixer(self.modules, allow_missing) |
| 59 | |
| 60 | # NOTE: This method isn't (yet) part of the NodeVisitor API. |
| 61 | def visit_type_info(self, info: TypeInfo) -> None: |
| 62 | save_info = self.current_info |
| 63 | try: |
| 64 | self.current_info = info |
| 65 | if info.defn: |
| 66 | info.defn.accept(self) |
| 67 | if info.names: |
| 68 | self.visit_symbol_table(info.names) |
| 69 | if info.bases: |
| 70 | for base in info.bases: |
| 71 | base.accept(self.type_fixer) |
| 72 | if info._promote: |
| 73 | for p in info._promote: |
| 74 | p.accept(self.type_fixer) |
| 75 | if info.tuple_type: |
| 76 | info.tuple_type.accept(self.type_fixer) |
| 77 | info.update_tuple_type(info.tuple_type) |
| 78 | if info.special_alias: |
| 79 | info.special_alias.alias_tvars = list(info.defn.type_vars) |
| 80 | for i, t in enumerate(info.defn.type_vars): |
| 81 | if isinstance(t, TypeVarTupleType): |
| 82 | info.special_alias.tvar_tuple_index = i |
| 83 | if info.typeddict_type: |
| 84 | info.typeddict_type.accept(self.type_fixer) |
| 85 | info.update_typeddict_type(info.typeddict_type) |
| 86 | if info.special_alias: |
| 87 | info.special_alias.alias_tvars = list(info.defn.type_vars) |
| 88 | for i, t in enumerate(info.defn.type_vars): |
| 89 | if isinstance(t, TypeVarTupleType): |
| 90 | info.special_alias.tvar_tuple_index = i |
| 91 | if info.declared_metaclass: |
| 92 | info.declared_metaclass.accept(self.type_fixer) |
| 93 | if info.metaclass_type: |
| 94 | info.metaclass_type.accept(self.type_fixer) |
| 95 | if info.self_type: |
| 96 | info.self_type.accept(self.type_fixer) |
| 97 | if info.alt_promote: |
| 98 | info.alt_promote.accept(self.type_fixer) |
| 99 | instance = Instance(info, []) |
| 100 | # Hack: We may also need to add a backwards promotion (from int to native int), |
| 101 | # since it might not be serialized. |
| 102 | if instance not in info.alt_promote.type._promote: |
| 103 | info.alt_promote.type._promote.append(instance) |
| 104 | if info._mro_refs: |
| 105 | info.mro = [ |
| 106 | lookup_fully_qualified_typeinfo( |
no outgoing calls
no test coverage detected
searching dependent graphs…