MCPcopy Index your code
hub / github.com/RustPython/RustPython / _find_method_definition

Function _find_method_definition

scripts/update_lib/cmd_auto_mark.py:442–462  ·  view source on GitHub ↗

Find the class where a method is actually defined (BFS).

(
    class_name: str, method_name: str, class_bases: dict, class_methods: dict
)

Source from the content-addressed store, hash-verified

440
441
442def _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
465def _find_all_inheritors(

Callers 3

_consolidate_to_parentFunction · 0.85
_find_all_inheritorsFunction · 0.85
remove_expected_failuresFunction · 0.85

Calls 6

setFunction · 0.85
listClass · 0.85
getMethod · 0.45
popMethod · 0.45
addMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected