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

Function formatargvalues

Lib/inspect.py:1388–1409  ·  view source on GitHub ↗

Format an argument spec from the 4 values returned by getargvalues. The first four arguments are (args, varargs, varkw, locals). The next four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is

(args, varargs, varkw, locals,
                    formatarg=str,
                    formatvarargs=lambda name: '*' + name,
                    formatvarkw=lambda name: '**' + name,
                    formatvalue=lambda value: '=' + repr(value))

Source from the content-addressed store, hash-verified

1386
1387
1388def formatargvalues(args, varargs, varkw, locals,
1389 formatarg=str,
1390 formatvarargs=lambda name: '*' + name,
1391 formatvarkw=lambda name: '**' + name,
1392 formatvalue=lambda value: '=' + repr(value)):
1393 """Format an argument spec from the 4 values returned by getargvalues.
1394
1395 The first four arguments are (args, varargs, varkw, locals). The
1396 next four arguments are the corresponding optional formatting functions
1397 that are called to turn names and values into strings. The ninth
1398 argument is an optional function to format the sequence of arguments."""
1399 def convert(name, locals=locals,
1400 formatarg=formatarg, formatvalue=formatvalue):
1401 return formatarg(name) + formatvalue(locals[name])
1402 specs = []
1403 for i in range(len(args)):
1404 specs.append(convert(args[i]))
1405 if varargs:
1406 specs.append(formatvarargs(varargs) + formatvalue(locals[varargs]))
1407 if varkw:
1408 specs.append(formatvarkw(varkw) + formatvalue(locals[varkw]))
1409 return '(' + ', '.join(specs) + ')'
1410
1411def _missing_arguments(f_name, argnames, pos, values):
1412 names = [repr(name) for name in argnames if name not in values]

Callers

nothing calls this directly

Calls 3

convertFunction · 0.70
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…