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

Function _python_param_names

graphify/extractors/python_scope.py:7–35  ·  view source on GitHub ↗

Plain parameter identifiers declared on a Python `parameters` node. Covers positional/keyword params plus `*args` / `**kwargs` and typed or default forms — anything that binds a local name the function body can shadow a module-level definition with.

(params_node, source: bytes)

Source from the content-addressed store, hash-verified

5
6
7def _python_param_names(params_node, source: bytes) -> set[str]:
8 """Plain parameter identifiers declared on a Python `parameters` node.
9
10 Covers positional/keyword params plus `*args` / `**kwargs` and typed or
11 default forms — anything that binds a local name the function body can shadow
12 a module-level definition with.
13 """
14 out: set[str] = set()
15 if params_node is None:
16 return out
17 for child in params_node.children:
18 if child.type == "identifier":
19 out.add(_read_text(child, source))
20 elif child.type in (
21 "typed_parameter",
22 "default_parameter",
23 "typed_default_parameter",
24 "list_splat_pattern",
25 "dictionary_splat_pattern",
26 ):
27 # The bound name is the first identifier child (the rest is type/default).
28 name_n = child.child_by_field_name("name")
29 if name_n is None:
30 name_n = next(
31 (c for c in child.children if c.type == "identifier"), None
32 )
33 if name_n is not None:
34 out.add(_read_text(name_n, source))
35 return out
36
37
38def _python_param_shadow_checker(source: bytes):

Callers 5

factsFunction · 0.90
factsFunction · 0.85

Calls 1

_read_textFunction · 0.90

Tested by

no test coverage detected