mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
gh-102721: Improve coverage of _collections_abc._CallableGenericAlias (#102722)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
b0ec6253c9
commit
fbe82fdd77
2 changed files with 32 additions and 14 deletions
|
|
@ -481,15 +481,8 @@ class _CallableGenericAlias(GenericAlias):
|
|||
# rather than the default types.GenericAlias object. Most of the
|
||||
# code is copied from typing's _GenericAlias and the builtin
|
||||
# types.GenericAlias.
|
||||
|
||||
if not isinstance(item, tuple):
|
||||
item = (item,)
|
||||
# A special case in PEP 612 where if X = Callable[P, int],
|
||||
# then X[int, str] == X[[int, str]].
|
||||
if (len(self.__parameters__) == 1
|
||||
and _is_param_expr(self.__parameters__[0])
|
||||
and item and not _is_param_expr(item[0])):
|
||||
item = (item,)
|
||||
|
||||
new_args = super().__getitem__(item).__args__
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue