MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / rebound_names

Function rebound_names

graphify/extractors/python_scope.py:51–70  ·  view source on GitHub ↗
(body)

Source from the content-addressed store, hash-verified

49 scopes: dict[int, tuple[set[str], set[str]]] = {}
50
51 def rebound_names(body) -> set[str]:
52 names: set[str] = set()
53 pending = list(body.named_children)
54 while pending:
55 node = pending.pop()
56 kind = node.type
57 if kind in ("function_definition", "class_definition"):
58 name = node.child_by_field_name("name")
59 if name is not None:
60 names.add(_read_text(name, source))
61 elif kind == "global_statement":
62 names.update(_read_text(c, source) for c in node.named_children)
63 elif kind in ("import_statement", "import_from_statement"):
64 for item in node.children_by_field_name("name"):
65 alias = item.child_by_field_name("alias")
66 text = _read_text(item if alias is None else alias, source)
67 names.add(text.split(".")[0] if kind == "import_statement" else text)
68 elif kind != "lambda":
69 pending.extend(node.named_children)
70 return names
71
72 def facts(scope, body) -> tuple[set[str], set[str]]:
73 if scope.id not in scopes:

Callers 1

factsFunction · 0.85

Calls 2

_read_textFunction · 0.90
updateMethod · 0.80

Tested by

no test coverage detected