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

Method __init__

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

Constructs Signature from the given list of Parameter objects and 'return_annotation'. All arguments are optional.

(self, parameters=None, *, return_annotation=_empty,
                 __validate_parameters__=True)

Source from the content-addressed store, hash-verified

2953 empty = _empty
2954
2955 def __init__(self, parameters=None, *, return_annotation=_empty,
2956 __validate_parameters__=True):
2957 """Constructs Signature from the given list of Parameter
2958 objects and 'return_annotation'. All arguments are optional.
2959 """
2960
2961 if parameters is None:
2962 params = OrderedDict()
2963 else:
2964 if __validate_parameters__:
2965 params = OrderedDict()
2966 top_kind = _POSITIONAL_ONLY
2967 seen_default = False
2968
2969 for param in parameters:
2970 kind = param.kind
2971 name = param.name
2972
2973 if kind < top_kind:
2974 msg = (
2975 'wrong parameter order: {} parameter before {} '
2976 'parameter'
2977 )
2978 msg = msg.format(top_kind.description,
2979 kind.description)
2980 raise ValueError(msg)
2981 elif kind > top_kind:
2982 top_kind = kind
2983
2984 if kind in (_POSITIONAL_ONLY, _POSITIONAL_OR_KEYWORD):
2985 if param.default is _empty:
2986 if seen_default:
2987 # No default for this parameter, but the
2988 # previous parameter of had a default
2989 msg = 'non-default argument follows default ' \
2990 'argument'
2991 raise ValueError(msg)
2992 else:
2993 # There is a default for this parameter.
2994 seen_default = True
2995
2996 if name in params:
2997 msg = 'duplicate parameter name: {!r}'.format(name)
2998 raise ValueError(msg)
2999
3000 params[name] = param
3001 else:
3002 params = OrderedDict((param.name, param) for param in parameters)
3003
3004 self._parameters = types.MappingProxyType(params)
3005 self._return_annotation = return_annotation
3006
3007 @classmethod
3008 def from_callable(cls, obj, *,

Callers

nothing calls this directly

Calls 2

OrderedDictClass · 0.90
formatMethod · 0.45

Tested by

no test coverage detected