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

Function _too_many

Lib/inspect.py:1427–1446  ·  view source on GitHub ↗
(f_name, args, kwonly, varargs, defcount, given, values)

Source from the content-addressed store, hash-verified

1425 "" if missing == 1 else "s", s))
1426
1427def _too_many(f_name, args, kwonly, varargs, defcount, given, values):
1428 atleast = len(args) - defcount
1429 kwonly_given = len([arg for arg in kwonly if arg in values])
1430 if varargs:
1431 plural = atleast != 1
1432 sig = "at least %d" % (atleast,)
1433 elif defcount:
1434 plural = True
1435 sig = "from %d to %d" % (atleast, len(args))
1436 else:
1437 plural = len(args) != 1
1438 sig = str(len(args))
1439 kwonly_sig = ""
1440 if kwonly_given:
1441 msg = " positional argument%s (and %d keyword-only argument%s)"
1442 kwonly_sig = (msg % ("s" if given != 1 else "", kwonly_given,
1443 "s" if kwonly_given != 1 else ""))
1444 raise TypeError("%s() takes %s positional argument%s but %d%s %s given" %
1445 (f_name, sig, "s" if plural else "", given, kwonly_sig,
1446 "was" if given == 1 and not kwonly_given else "were"))
1447
1448def getcallargs(func, /, *positional, **named):
1449 """Get the mapping of arguments to values.

Callers 1

getcallargsFunction · 0.85

Calls 1

strFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…