class documentation

Model a function argument definition.

This demonstrate the Arg.to_parameter method:

>>> from libstatic import Project
>>> node = ast.parse('def f(a:int, b:object=None, *, key:str, **kwargs):...')
>>> p = Project()
>>> _ = p.add_module(node, 'test')
>>> p.analyze_project()
>>> func_node = node.body[0]
>>> args = (p.state.get_def(n) for n in ast.walk(func_node.args) if isinstance(n, ast.arg))
>>> parameters = [a.to_parameter() for a in args]
>>> sig = inspect.Signature(parameters)
>>> str(sig)
'(a:...Name..., b:...Name...=...Constant..., *, key:...Name..., **kwargs)'
Method to_parameter Cast this Arg instance into a inspect.Parameter instance.
Instance Variable default Undocumented
Instance Variable kind One of Parameter.POSITIONAL_ONLY, Parameter.POSITIONAL_OR_KEYWORD, Parameter.VAR_POSITIONAL, Parameter.KEYWORD_ONLY or Parameter.VAR_KEYWORD.
Instance Variable node Undocumented

Inherited from NameDef:

Method name If the node associated to this Def has a name, returns this name. Otherwise returns None.

Inherited from Def (via NameDef):

Method add_user Undocumented
Method users The list of ast entity that holds a reference to this node.
Instance Variable islive Undocumented
Method _setup Undocumented
Method _str Undocumented
Instance Variable _users Undocumented
def to_parameter(self) -> inspect.Parameter: (source)

Cast this Arg instance into a inspect.Parameter instance.

Undocumented

One of Parameter.POSITIONAL_ONLY, Parameter.POSITIONAL_OR_KEYWORD, Parameter.VAR_POSITIONAL, Parameter.KEYWORD_ONLY or Parameter.VAR_KEYWORD.

See Also
inspect.Parameter.kind

Undocumented