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

Function getfullargspec

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

Get the names and default values of a callable object's parameters. A tuple of seven things is returned: (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). 'args' is a list of the parameter names. 'varargs' and 'varkw' are the names of the * and ** param

(func)

Source from the content-addressed store, hash-verified

1330 'args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations')
1331
1332def getfullargspec(func):
1333 """Get the names and default values of a callable object's parameters.
1334
1335 A tuple of seven things is returned:
1336 (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations).
1337 'args' is a list of the parameter names.
1338 'varargs' and 'varkw' are the names of the * and ** parameters or None.
1339 'defaults' is an n-tuple of the default values of the last n parameters.
1340 'kwonlyargs' is a list of keyword-only parameter names.
1341 'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults.
1342 'annotations' is a dictionary mapping parameter names to annotations.
1343
1344 Notable differences from inspect.signature():
1345 - the "self" parameter is always reported, even for bound methods
1346 - wrapper chains defined by __wrapped__ *not* unwrapped automatically
1347 """
1348 try:
1349 # Re: `skip_bound_arg=False`
1350 #
1351 # There is a notable difference in behaviour between getfullargspec
1352 # and Signature: the former always returns 'self' parameter for bound
1353 # methods, whereas the Signature always shows the actual calling
1354 # signature of the passed object.
1355 #
1356 # To simulate this behaviour, we "unbind" bound methods, to trick
1357 # inspect.signature to always return their first parameter ("self",
1358 # usually)
1359
1360 # Re: `follow_wrapper_chains=False`
1361 #
1362 # getfullargspec() historically ignored __wrapped__ attributes,
1363 # so we ensure that remains the case in 3.3+
1364
1365 sig = _signature_from_callable(func,
1366 follow_wrapper_chains=False,
1367 skip_bound_arg=False,
1368 sigcls=Signature,
1369 eval_str=False)
1370 except Exception as ex:
1371 # Most of the times 'signature' will raise ValueError.
1372 # But, it can also raise AttributeError, and, maybe something
1373 # else. So to be fully backwards compatible, we catch all
1374 # possible exceptions here, and reraise a TypeError.
1375 raise TypeError('unsupported callable') from ex
1376
1377 args = []
1378 varargs = None
1379 varkw = None
1380 posonlyargs = []
1381 kwonlyargs = []
1382 annotations = {}
1383 defaults = ()
1384 kwdefaults = {}
1385
1386 if sig.return_annotation is not sig.empty:
1387 annotations['return'] = sig.return_annotation
1388
1389 for param in sig.parameters.values():

Callers 1

getcallargsFunction · 0.85

Calls 3

_signature_from_callableFunction · 0.85
valuesMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected