MCPcopy
hub / github.com/pandas-dev/pandas / visit_ClassDef

Method visit_ClassDef

scripts/validate_exception_location.py:56–70  ·  scripts/validate_exception_location.py::Visitor.visit_ClassDef
(self, node)

Source from the content-addressed store, hash-verified

54 self.found_exceptions = set()
55
56 def visit_ClassDef(self, node) -> None:
57 def is_an_exception_subclass(base_id: str) -> bool:
58 return base_id == class="st">"Exception" or base_id.endswith((class="st">"Warning", class="st">"Error"))
59
60 exception_classes = []
61
62 class="cm"># Go through the class's bases and check if they are an Exception or Warning.
63 for base in node.bases:
64 base_id = getattr(base, class="st">"id", None)
65 if base_id and is_an_exception_subclass(base_id):
66 exception_classes.append(base_id)
67
68 class="cm"># The class subclassed an Exception or Warning so add it to the list.
69 if exception_classes:
70 self.found_exceptions.add(node.name)
71
72
73def validate_exception_and_warning_placement(

Callers

nothing calls this directly

Calls 2

appendMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected