INNER CODE UNIT · Python
_find_callsites
blockscout/blockscout · .agents/skills/openapi-spec/scripts/leaf-schemas-collect-facts.py:96
def _find_callsites(
short_name: str,
exclude_path: pathlib.Path,
) -> list[dict]:
"""Find up to MAX_CALLSITES references to a leaf outside its own file.
Matches either `General.<ShortName>` (qualified) or bare `<ShortName>`
(used in files that do `alias …General.{X, Y}` and reference X without
the prefix). Bare-name false positives on these PascalCase identifiers
are rare; the cataloger agent reads each callsite's line context
anyway and can sanity-check.
Uses `\\b` to avoid prefix-matching (e.g. `AddressHash` matching
`AddressHashNullable`). One result per distinct file to spread coverage
rather than collapsing on a single popular caller.
"""
pattern = rf"\b(?:General\.)?{re.escape(short_name)}\b"
try: