(cls, data: ReadBuffer)
| 4328 | |
| 4329 | @classmethod |
| 4330 | def read(cls, data: ReadBuffer) -> TypeInfo: |
| 4331 | names = SymbolTable.read(data) |
| 4332 | assert read_tag(data) == CLASS_DEF |
| 4333 | defn = ClassDef.read(data) |
| 4334 | module_name = read_str(data) |
| 4335 | ti = TypeInfo(names, defn, module_name) |
| 4336 | ti._fullname = read_str(data) |
| 4337 | attrs = read_str_list(data) |
| 4338 | statuses = read_int_list(data) |
| 4339 | ti.abstract_attributes = list(zip(attrs, statuses)) |
| 4340 | ti.type_vars = read_str_list(data) |
| 4341 | ti.has_param_spec_type = read_bool(data) |
| 4342 | ti.bases = [] |
| 4343 | assert read_tag(data) == LIST_GEN |
| 4344 | for _ in range(read_int_bare(data)): |
| 4345 | assert read_tag(data) == mypy.types.INSTANCE |
| 4346 | ti.bases.append(mypy.types.Instance.read(data)) |
| 4347 | # NOTE: ti.mro will be set in the fixup phase based on these |
| 4348 | # names. The reason we need to store the mro instead of just |
| 4349 | # recomputing it from base classes has to do with a subtle |
| 4350 | # point about fine-grained incremental: the cache files might |
| 4351 | # not be loaded until after a class in the mro has changed its |
| 4352 | # bases, which causes the mro to change. If we recomputed our |
| 4353 | # mro, we would compute the *new* mro, which leaves us with no |
| 4354 | # way to detect that the mro has changed! Thus, we need to make |
| 4355 | # sure to load the original mro so that once the class is |
| 4356 | # rechecked, it can tell that the mro has changed. |
| 4357 | ti._mro_refs = read_str_list(data) |
| 4358 | ti._promote = cast(list[mypy.types.ProperType], mypy.types.read_type_list(data)) |
| 4359 | if (tag := read_tag(data)) != LITERAL_NONE: |
| 4360 | assert tag == mypy.types.INSTANCE |
| 4361 | ti.alt_promote = mypy.types.Instance.read(data) |
| 4362 | if (tag := read_tag(data)) != LITERAL_NONE: |
| 4363 | assert tag == mypy.types.INSTANCE |
| 4364 | ti.declared_metaclass = mypy.types.Instance.read(data) |
| 4365 | if (tag := read_tag(data)) != LITERAL_NONE: |
| 4366 | assert tag == mypy.types.INSTANCE |
| 4367 | ti.metaclass_type = mypy.types.Instance.read(data) |
| 4368 | if (tag := read_tag(data)) != LITERAL_NONE: |
| 4369 | assert tag == mypy.types.TUPLE_TYPE |
| 4370 | ti.tuple_type = mypy.types.TupleType.read(data) |
| 4371 | if (tag := read_tag(data)) != LITERAL_NONE: |
| 4372 | assert tag == mypy.types.TYPED_DICT_TYPE |
| 4373 | ti.typeddict_type = mypy.types.TypedDictType.read(data) |
| 4374 | ( |
| 4375 | ti.is_abstract, |
| 4376 | ti.is_enum, |
| 4377 | ti.fallback_to_any, |
| 4378 | ti.meta_fallback_to_any, |
| 4379 | ti.is_named_tuple, |
| 4380 | ti.is_newtype, |
| 4381 | ti.is_protocol, |
| 4382 | ti.runtime_protocol, |
| 4383 | ti.is_final, |
| 4384 | ti.is_disjoint_base, |
| 4385 | ti.is_intersection, |
| 4386 | ) = read_flags(data, num_flags=11) |
| 4387 | ti.metadata = read_json(data) |
nothing calls this directly
no test coverage detected