MCPcopy Index your code
hub / github.com/python/cpython / getargs

Function getargs

Lib/inspect.py:1228–1252  ·  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

1226Arguments = namedtuple('Arguments', 'args, varargs, varkw')
1227
1228def getargs(co):
1229 """Get information about the arguments accepted by a code object.
1230
1231 Three things are returned: (args, varargs, varkw), where
1232 'args' is the list of argument names. Keyword-only arguments are
1233 appended. 'varargs' and 'varkw' are the names of the * and **
1234 arguments or None."""
1235 if not iscode(co):
1236 raise TypeError('{!r} is not a code object'.format(co))
1237
1238 names = co.co_varnames
1239 nargs = co.co_argcount
1240 nkwargs = co.co_kwonlyargcount
1241 args = list(names[:nargs])
1242 kwonlyargs = list(names[nargs:nargs+nkwargs])
1243
1244 nargs += nkwargs
1245 varargs = None
1246 if co.co_flags & CO_VARARGS:
1247 varargs = co.co_varnames[nargs]
1248 nargs = nargs + 1
1249 varkw = None
1250 if co.co_flags & CO_VARKEYWORDS:
1251 varkw = co.co_varnames[nargs]
1252 return Arguments(args + kwonlyargs, varargs, varkw)
1253
1254
1255FullArgSpec = namedtuple('FullArgSpec',

Callers 1

getargvaluesFunction · 0.85

Calls 3

iscodeFunction · 0.85
listClass · 0.85
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…