Skip to content

Commit 76bb212

Browse files
authored
Correct _CallableGenericAlias
1 parent d931725 commit 76bb212

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

Lib/_collections_abc.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,10 @@ def __subclasshook__(cls, C):
459459

460460

461461
class _CallableGenericAlias(GenericAlias):
462-
""" Represent `Callable[argtypes, resulttype]`.
462+
""" Represent `Callable[paramtypes, returntype]`.
463463
464-
This sets ``__args__`` to a tuple containing the flattened ``argtypes``
465-
followed by ``resulttype``.
464+
This sets ``__args__`` to a tuple containing the flattened ``paramtypes``
465+
followed by ``returntype``.
466466
467467
Example: ``Callable[[int, str], float]`` sets ``__args__`` to
468468
``(int, str, float)``.
@@ -473,13 +473,13 @@ class _CallableGenericAlias(GenericAlias):
473473
def __new__(cls, origin, args):
474474
if not (isinstance(args, tuple) and len(args) == 2):
475475
raise TypeError(
476-
"Callable must be used as Callable[[arg, ...], result].")
477-
t_args, t_result = args
478-
if isinstance(t_args, (tuple, list)):
479-
args = (*t_args, t_result)
480-
elif not _is_param_expr(t_args):
476+
"Callable must be used as Callable[[paramtype1, ...], returntype].")
477+
t_params, t_return = args
478+
if isinstance(t_params, (tuple, list)):
479+
args = (*t_params, t_return)
480+
elif not _is_param_expr(t_params):
481481
raise TypeError(f"Expected a list of types, an ellipsis, "
482-
f"ParamSpec, or Concatenate. Got {t_args}")
482+
f"ParamSpec, or Concatenate. Got {t_params}")
483483
return super().__new__(cls, origin, args)
484484

485485
def __repr__(self):
@@ -508,9 +508,9 @@ def __getitem__(self, item):
508508

509509
# args[0] occurs due to things like Z[[int, str, bool]] from PEP 612
510510
if not isinstance(new_args[0], (tuple, list)):
511-
t_result = new_args[-1]
512-
t_args = new_args[:-1]
513-
new_args = (t_args, t_result)
511+
t_params = new_args[:-1]
512+
t_return = new_args[-1]
513+
new_args = (t_params, t_return)
514514
return _CallableGenericAlias(Callable, tuple(new_args))
515515

516516
def _is_param_expr(obj):

0 commit comments

Comments
 (0)