(f_name, args, kwonly, varargs, defcount, given, values)
| 1401 | "" if missing == 1 else "s", s)) |
| 1402 | |
| 1403 | def _too_many(f_name, args, kwonly, varargs, defcount, given, values): |
| 1404 | atleast = len(args) - defcount |
| 1405 | kwonly_given = len([arg for arg in kwonly if arg in values]) |
| 1406 | if varargs: |
| 1407 | plural = atleast != 1 |
| 1408 | sig = "at least %d" % (atleast,) |
| 1409 | elif defcount: |
| 1410 | plural = True |
| 1411 | sig = "from %d to %d" % (atleast, len(args)) |
| 1412 | else: |
| 1413 | plural = len(args) != 1 |
| 1414 | sig = str(len(args)) |
| 1415 | kwonly_sig = "" |
| 1416 | if kwonly_given: |
| 1417 | msg = " positional argument%s (and %d keyword-only argument%s)" |
| 1418 | kwonly_sig = (msg % ("s" if given != 1 else "", kwonly_given, |
| 1419 | "s" if kwonly_given != 1 else "")) |
| 1420 | raise TypeError("%s() takes %s positional argument%s but %d%s %s given" % |
| 1421 | (f_name, sig, "s" if plural else "", given, kwonly_sig, |
| 1422 | "was" if given == 1 and not kwonly_given else "were")) |
| 1423 | |
| 1424 | def getcallargs(func, /, *positional, **named): |
| 1425 | """Get the mapping of arguments to values. |
no test coverage detected