MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / Parameter

Class Parameter

tools/python-3.11.9-amd64/Lib/inspect.py:2637–2792  ·  view source on GitHub ↗

Represents a parameter in a function signature. Has the following public attributes: * name : str The name of the parameter as a string. * default : object The default value for the parameter if specified. If the parameter has no default value, this att

Source from the content-addressed store, hash-verified

2635
2636
2637class Parameter:
2638 """Represents a parameter in a function signature.
2639
2640 Has the following public attributes:
2641
2642 * name : str
2643 The name of the parameter as a string.
2644 * default : object
2645 The default value for the parameter if specified. If the
2646 parameter has no default value, this attribute is set to
2647 `Parameter.empty`.
2648 * annotation
2649 The annotation for the parameter if specified. If the
2650 parameter has no annotation, this attribute is set to
2651 `Parameter.empty`.
2652 * kind : str
2653 Describes how argument values are bound to the parameter.
2654 Possible values: `Parameter.POSITIONAL_ONLY`,
2655 `Parameter.POSITIONAL_OR_KEYWORD`, `Parameter.VAR_POSITIONAL`,
2656 `Parameter.KEYWORD_ONLY`, `Parameter.VAR_KEYWORD`.
2657 """
2658
2659 __slots__ = ('_name', '_kind', '_default', '_annotation')
2660
2661 POSITIONAL_ONLY = _POSITIONAL_ONLY
2662 POSITIONAL_OR_KEYWORD = _POSITIONAL_OR_KEYWORD
2663 VAR_POSITIONAL = _VAR_POSITIONAL
2664 KEYWORD_ONLY = _KEYWORD_ONLY
2665 VAR_KEYWORD = _VAR_KEYWORD
2666
2667 empty = _empty
2668
2669 def __init__(self, name, kind, *, default=_empty, annotation=_empty):
2670 try:
2671 self._kind = _ParameterKind(kind)
2672 except ValueError:
2673 raise ValueError(f'value {kind!r} is not a valid Parameter.kind')
2674 if default is not _empty:
2675 if self._kind in (_VAR_POSITIONAL, _VAR_KEYWORD):
2676 msg = '{} parameters cannot have default values'
2677 msg = msg.format(self._kind.description)
2678 raise ValueError(msg)
2679 self._default = default
2680 self._annotation = annotation
2681
2682 if name is _empty:
2683 raise ValueError('name is a required attribute for Parameter')
2684
2685 if not isinstance(name, str):
2686 msg = 'name must be a str, not a {}'.format(type(name).__name__)
2687 raise TypeError(msg)
2688
2689 if name[0] == '.' and name[1:].isdigit():
2690 # These are implicit arguments generated by comprehensions. In
2691 # order to provide a friendlier interface to users, we recast
2692 # their name as "implicitN" and treat them as positional-only.
2693 # See issue 19611.
2694 if self._kind != _POSITIONAL_OR_KEYWORD:

Callers 2

pFunction · 0.70
_signature_from_functionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected