module documentation

Undocumented

Class ArgSpec Undocumented
Function iter_arguments Yields all arguments of the given ast.arguments node as ArgSpec instances.
def iter_arguments(args: ast.arguments) -> Iterator[ArgSpec]: (source) ΒΆ

Yields all arguments of the given ast.arguments node as ArgSpec instances.

>>> node = ast.parse('def f(a:int, b:object=None, *, key:Callable, **kwargs):...')
>>> args = iter_arguments(node.body[0].args)
>>> parameters = [inspect.Parameter(a.node.arg, a.kind,
... default=a.default or inspect.Parameter.empty,
... annotation=a.node.annotation or inspect.Parameter.empty) for a in args]
>>> sig = inspect.Signature(parameters)
>>> str(sig)
'(a:...Name..., b:...Name...=...Constant..., *, key:...Name..., **kwargs)'