diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-06-01 08:00:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-01 08:00:15 (GMT) |
commit | 2085bd0877e17ad4d98a4586d5eabb6faecbb190 (patch) | |
tree | c25b20d33ebf4d64a28abb8591f4ff7acf90614c /Lib/inspect.py | |
parent | 4a686504eb2bbf69adf78077458508a7ba131667 (diff) | |
download | cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.zip cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.tar.gz cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.tar.bz2 |
bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index a4f28f7..ca81a24 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -1329,14 +1329,12 @@ def _too_many(f_name, args, kwonly, varargs, defcount, given, values): (f_name, sig, "s" if plural else "", given, kwonly_sig, "was" if given == 1 and not kwonly_given else "were")) -def getcallargs(*func_and_positional, **named): +def getcallargs(func, /, *positional, **named): """Get the mapping of arguments to values. A dict is returned, with keys the function argument names (including the names of the * and ** arguments, if any), and values the respective bound values from 'positional' and 'named'.""" - func = func_and_positional[0] - positional = func_and_positional[1:] spec = getfullargspec(func) args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = spec f_name = func.__name__ @@ -3027,19 +3025,19 @@ class Signature: return self._bound_arguments_cls(self, arguments) - def bind(*args, **kwargs): + def bind(self, /, *args, **kwargs): """Get a BoundArguments object, that maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. """ - return args[0]._bind(args[1:], kwargs) + return self._bind(args, kwargs) - def bind_partial(*args, **kwargs): + def bind_partial(self, /, *args, **kwargs): """Get a BoundArguments object, that partially maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. """ - return args[0]._bind(args[1:], kwargs, partial=True) + return self._bind(args, kwargs, partial=True) def __reduce__(self): return (type(self), |