MCPcopy Index your code
hub / github.com/RustPython/RustPython / getargs

Function getargs

Lib/inspect.py:1204–1228  ·  view source on GitHub ↗

Get information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where 'args' is the list of argument names. Keyword-only arguments are appended. 'varargs' and 'varkw' are the names of the * and ** arguments or None.

(co)

Source from the content-addressed store, hash-verified

1202Arguments = namedtuple('Arguments', 'args, varargs, varkw')
1203
1204def getargs(co):
1205 """Get information about the arguments accepted by a code object.
1206
1207 Three things are returned: (args, varargs, varkw), where
1208 'args' is the list of argument names. Keyword-only arguments are
1209 appended. 'varargs' and 'varkw' are the names of the * and **
1210 arguments or None."""
1211 if not iscode(co):
1212 raise TypeError('{!r} is not a code object'.format(co))
1213
1214 names = co.co_varnames
1215 nargs = co.co_argcount
1216 nkwargs = co.co_kwonlyargcount
1217 args = list(names[:nargs])
1218 kwonlyargs = list(names[nargs:nargs+nkwargs])
1219
1220 nargs += nkwargs
1221 varargs = None
1222 if co.co_flags & CO_VARARGS:
1223 varargs = co.co_varnames[nargs]
1224 nargs = nargs + 1
1225 varkw = None
1226 if co.co_flags & CO_VARKEYWORDS:
1227 varkw = co.co_varnames[nargs]
1228 return Arguments(args + kwonlyargs, varargs, varkw)
1229
1230
1231FullArgSpec = namedtuple('FullArgSpec',

Callers 1

getargvaluesFunction · 0.85

Calls 4

iscodeFunction · 0.85
listClass · 0.85
ArgumentsClass · 0.85
formatMethod · 0.45

Tested by

no test coverage detected