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 ** parameters
(func)
| 1256 | 'args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations') |
| 1257 | |
| 1258 | def getfullargspec(func): |
| 1259 | """Get the names and default values of a callable object's parameters. |
| 1260 | |
| 1261 | A tuple of seven things is returned: |
| 1262 | (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). |
| 1263 | 'args' is a list of the parameter names. |
| 1264 | 'varargs' and 'varkw' are the names of the * and ** parameters or None. |
| 1265 | 'defaults' is an n-tuple of the default values of the last n parameters. |
| 1266 | 'kwonlyargs' is a list of keyword-only parameter names. |
| 1267 | 'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults. |
| 1268 | 'annotations' is a dictionary mapping parameter names to annotations. |
| 1269 | |
| 1270 | Notable differences from inspect.signature(): |
| 1271 | - the "self" parameter is always reported, even for bound methods |
| 1272 | - wrapper chains defined by __wrapped__ *not* unwrapped automatically |
| 1273 | """ |
| 1274 | try: |
| 1275 | # Re: `skip_bound_arg=False` |
| 1276 | # |
| 1277 | # There is a notable difference in behaviour between getfullargspec |
| 1278 | # and Signature: the former always returns 'self' parameter for bound |
| 1279 | # methods, whereas the Signature always shows the actual calling |
| 1280 | # signature of the passed object. |
| 1281 | # |
| 1282 | # To simulate this behaviour, we "unbind" bound methods, to trick |
| 1283 | # inspect.signature to always return their first parameter ("self", |
| 1284 | # usually) |
| 1285 | |
| 1286 | # Re: `follow_wrapper_chains=False` |
| 1287 | # |
| 1288 | # getfullargspec() historically ignored __wrapped__ attributes, |
| 1289 | # so we ensure that remains the case in 3.3+ |
| 1290 | |
| 1291 | sig = _signature_from_callable(func, |
| 1292 | follow_wrapper_chains=False, |
| 1293 | skip_bound_arg=False, |
| 1294 | sigcls=Signature, |
| 1295 | eval_str=False) |
| 1296 | except Exception as ex: |
| 1297 | # Most of the times 'signature' will raise ValueError. |
| 1298 | # But, it can also raise AttributeError, and, maybe something |
| 1299 | # else. So to be fully backwards compatible, we catch all |
| 1300 | # possible exceptions here, and reraise a TypeError. |
| 1301 | raise TypeError('unsupported callable') from ex |
| 1302 | |
| 1303 | args = [] |
| 1304 | varargs = None |
| 1305 | varkw = None |
| 1306 | posonlyargs = [] |
| 1307 | kwonlyargs = [] |
| 1308 | annotations = {} |
| 1309 | defaults = () |
| 1310 | kwdefaults = {} |
| 1311 | |
| 1312 | if sig.return_annotation is not sig.empty: |
| 1313 | annotations['return'] = sig.return_annotation |
| 1314 | |
| 1315 | for param in sig.parameters.values(): |
no test coverage detected
searching dependent graphs…