MCPcopy Index your code
hub / github.com/python/mypy / configure_tuple_base_class

Method configure_tuple_base_class

mypy/semanal.py:2703–2723  ·  view source on GitHub ↗
(self, defn: ClassDef, base: TupleType)

Source from the content-addressed store, hash-verified

2701 self.calculate_class_mro(defn, self.object_type)
2702
2703 def configure_tuple_base_class(self, defn: ClassDef, base: TupleType) -> Instance:
2704 info = defn.info
2705
2706 # There may be an existing valid tuple type from previous semanal iterations.
2707 # Use equality to check if it is the case.
2708 if info.tuple_type and info.tuple_type != base and not has_placeholder(info.tuple_type):
2709 self.fail("Class has two incompatible bases derived from tuple", defn)
2710 defn.has_incompatible_baseclass = True
2711 if has_placeholder(base):
2712 self.process_placeholder(
2713 None, "tuple base", defn, force_progress=base != info.tuple_type
2714 )
2715 info.update_tuple_type(base)
2716 self.setup_alias_type_vars(defn)
2717
2718 if base.partial_fallback.type.fullname == "builtins.tuple" and not has_placeholder(base):
2719 # Fallback can only be safely calculated after semantic analysis, since base
2720 # classes may be incomplete. Postpone the calculation.
2721 self.schedule_patch(PRIORITY_FALLBACKS, lambda: calculate_tuple_fallback(base))
2722
2723 return base.partial_fallback
2724
2725 def set_dummy_mro(self, info: TypeInfo) -> None:
2726 # Give it an MRO consisting of just the class itself and object.

Callers 1

Calls 7

failMethod · 0.95
process_placeholderMethod · 0.95
setup_alias_type_varsMethod · 0.95
schedule_patchMethod · 0.95
has_placeholderFunction · 0.90
calculate_tuple_fallbackFunction · 0.90
update_tuple_typeMethod · 0.80

Tested by

no test coverage detected