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

Function update_always_defined_attrs_using_subclasses

mypyc/analysis/attrdefined.py:400–414  ·  view source on GitHub ↗

Remove attributes not defined in all subclasses from always defined attrs.

(cl: ClassIR, seen: set[ClassIR])

Source from the content-addressed store, hash-verified

398
399
400def update_always_defined_attrs_using_subclasses(cl: ClassIR, seen: set[ClassIR]) -> None:
401 """Remove attributes not defined in all subclasses from always defined attrs."""
402 if cl in seen:
403 return
404 if cl.children is None:
405 # Subclasses are unknown
406 return
407 removed = set()
408 for attr in cl._always_initialized_attrs:
409 for child in cl.children:
410 update_always_defined_attrs_using_subclasses(child, seen)
411 if attr not in child._always_initialized_attrs:
412 removed.add(attr)
413 cl._always_initialized_attrs -= removed
414 seen.add(cl)
415
416
417def detect_undefined_bitmap(cl: ClassIR, seen: set[ClassIR]) -> None:

Callers 1

Calls 2

setClass · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…