class ArgTypeExpander: (source)
Utility class for mapping actual argument types to formal arguments.
One of the main responsibilities is to expand caller tuple *args and TypedDict **kwargs, and to keep track of which tuple/TypedDict items have already been consumed.
Example:
def f(x: int, *args: str) -> None: ... f(*(1, 'x', 1.1))
We'd call expand_actual_type three times:
- The first call would provide 'int' as the actual type of 'x' (from '1').
2. The second call would provide 'str' as one of the actual types for '*args'. 2. The third call would provide 'float' as one of the actual types for '*args'.
A single instance can process all the arguments for a single call. Each call needs a separate instance since instances have per-call state.
Method | __init__ |
Undocumented |
Method | expand_actual_type |
Return the actual (caller) type(s) of a formal argument with the given kinds. |
Instance Variable | context |
Undocumented |
Instance Variable | kwargs_used |
Undocumented |
Instance Variable | tuple_index |
Undocumented |
Return the actual (caller) type(s) of a formal argument with the given kinds.
If the actual argument is a tuple *args, return the next individual tuple item that maps to the formal arg.
If the actual argument is a TypedDict **kwargs, return the next matching typed dict value type based on formal argument name and kind.
This is supposed to be called for each formal, in order. Call multiple times per formal if multiple actuals map to a formal.
Parameters | |
actual_type:Type | Undocumented |
actual_kind:nodes.ArgKind | Undocumented |
formal_name:Optional[ | Undocumented |
formal_kind:nodes.ArgKind | Undocumented |
Returns | |
Type | Undocumented |