MCPcopy
hub / github.com/python/mypy / map_formals_to_actuals

Function map_formals_to_actuals

mypy/argmap.py:125–141  ·  view source on GitHub ↗

Calculate the reverse mapping of map_actuals_to_formals.

(
    actual_kinds: list[nodes.ArgKind],
    actual_names: Sequence[str | None] | None,
    formal_kinds: list[nodes.ArgKind],
    formal_names: list[str | None],
    actual_arg_type: Callable[[int], Type],
)

Source from the content-addressed store, hash-verified

123
124
125def map_formals_to_actuals(
126 actual_kinds: list[nodes.ArgKind],
127 actual_names: Sequence[str | None] | None,
128 formal_kinds: list[nodes.ArgKind],
129 formal_names: list[str | None],
130 actual_arg_type: Callable[[int], Type],
131) -> list[list[int]]:
132 """Calculate the reverse mapping of map_actuals_to_formals."""
133 formal_to_actual = map_actuals_to_formals(
134 actual_kinds, actual_names, formal_kinds, formal_names, actual_arg_type
135 )
136 # Now reverse the mapping.
137 actual_to_formal: list[list[int]] = [[] for _ in actual_kinds]
138 for formal, actuals in enumerate(formal_to_actual):
139 for actual in actuals:
140 actual_to_formal[actual].append(formal)
141 return actual_to_formal
142
143
144class ArgTypeExpander:

Calls 3

map_actuals_to_formalsFunction · 0.85
enumerateFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…