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

Function formatargvalues

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

1362
1363
1364def formatargvalues(args, varargs, varkw, locals,
1365 formatarg=str,
1366 formatvarargs=lambda name: '*' + name,
1367 formatvarkw=lambda name: '**' + name,
1368 formatvalue=lambda value: '=' + repr(value)):
1369 """Format an argument spec from the 4 values returned by getargvalues.
1370
1371 The first four arguments are (args, varargs, varkw, locals). The
1372 next four arguments are the corresponding optional formatting functions
1373 that are called to turn names and values into strings. The ninth
1374 argument is an optional function to format the sequence of arguments."""
1375 def convert(name, locals=locals,
1376 formatarg=formatarg, formatvalue=formatvalue):
1377 return formatarg(name) + formatvalue(locals[name])
1378 specs = []
1379 for i in range(len(args)):
1380 specs.append(convert(args[i]))
1381 if varargs:
1382 specs.append(formatvarargs(varargs) + formatvalue(locals[varargs]))
1383 if varkw:
1384 specs.append(formatvarkw(varkw) + formatvalue(locals[varkw]))
1385 return '(' + ', '.join(specs) + ')'
1386
1387def _missing_arguments(f_name, argnames, pos, values):
1388 names = [repr(name) for name in argnames if name not in values]

Callers

nothing calls this directly

Calls 5

reprFunction · 0.85
lenFunction · 0.85
convertFunction · 0.70
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected