| 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 | |
| 73 | def validate_exception_and_warning_placement( |