gh-141560: Add annotation_format parameter to getfullargspec (#149457) · python/cpython@ff422bd

GitHub

@@ -1254,18 +1254,20 @@ def getargs(co):

12541254FullArgSpec=namedtuple('FullArgSpec',

12551255'args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations')

125612561257-defgetfullargspec(func):

1257+defgetfullargspec(func, *, annotation_format=Format.VALUE):

12581258"""Get the names and default values of a callable object's parameters.

125912591260- A tuple of seven things is returned:

1261- (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations).

1260+ A FullArgSpec namedtuple is returned, which has the following attributes:

12621261 'args' is a list of the parameter names.

12631262 'varargs' and 'varkw' are the names of the * and ** parameters or None.

12641263 'defaults' is an n-tuple of the default values of the last n parameters.

12651264 'kwonlyargs' is a list of keyword-only parameter names.

12661265 'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults.

12671266 'annotations' is a dictionary mapping parameter names to annotations.

126812671268+ The *annotation_format* parameter controls the format of the annotations.

1269+ See the annotationlib documentation for details.

1270+12691271 Notable differences from inspect.signature():

12701272 - the "self" parameter is always reported, even for bound methods

12711273 - wrapper chains defined by __wrapped__ *not* unwrapped automatically

@@ -1291,7 +1293,8 @@ def getfullargspec(func):

12911293follow_wrapper_chains=False,

12921294skip_bound_arg=False,

12931295sigcls=Signature,

1294-eval_str=False)

1296+eval_str=False,

1297+annotation_format=annotation_format)

12951298exceptExceptionasex:

12961299# Most of the times 'signature' will raise ValueError.

12971300# But, it can also raise AttributeError, and, maybe something