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

Method is_base_class

mypy/semanal.py:2822–2835  ·  view source on GitHub ↗

Determine if t is a base class of s (but do not use mro).

(self, t: TypeInfo, s: TypeInfo)

Source from the content-addressed store, hash-verified

2820 return not dup
2821
2822 def is_base_class(self, t: TypeInfo, s: TypeInfo) -> bool:
2823 """Determine if t is a base class of s (but do not use mro)."""
2824 # Search the base class graph for t, starting from s.
2825 worklist = [s]
2826 visited = {s}
2827 while worklist:
2828 nxt = worklist.pop()
2829 if nxt == t:
2830 return True
2831 for base in nxt.bases:
2832 if base.type not in visited:
2833 worklist.append(base.type)
2834 visited.add(base.type)
2835 return False
2836
2837 def get_declared_metaclass(
2838 self, name: str, metaclass_expr: Expression | None

Callers 1

verify_base_classesMethod · 0.95

Calls 3

appendMethod · 0.80
popMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected