Find the class where a method is actually defined (BFS).
(
class_name: str, method_name: str, class_bases: dict, class_methods: dict
)
| 440 | |
| 441 | |
| 442 | def _find_method_definition( |
| 443 | class_name: str, method_name: str, class_bases: dict, class_methods: dict |
| 444 | ) -> str | None: |
| 445 | """Find the class where a method is actually defined (BFS).""" |
| 446 | if method_name in class_methods.get(class_name, set()): |
| 447 | return class_name |
| 448 | |
| 449 | visited = set() |
| 450 | queue = list(class_bases.get(class_name, [])) |
| 451 | |
| 452 | while queue: |
| 453 | current = queue.pop(0) |
| 454 | if current in visited: |
| 455 | continue |
| 456 | visited.add(current) |
| 457 | |
| 458 | if method_name in class_methods.get(current, set()): |
| 459 | return current |
| 460 | queue.extend(class_bases.get(current, [])) |
| 461 | |
| 462 | return None |
| 463 | |
| 464 | |
| 465 | def _find_all_inheritors( |
no test coverage detected