You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Arguments ignored in substitution in typing.Callable #88956
>>> typing.List[C][int, str, float]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython/Lib/typing.py", line 309, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/home/serhiy/py/cpython/Lib/typing.py", line 1028, in __getitem__
_check_generic(self, params, len(self.__parameters__))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/serhiy/py/cpython/Lib/typing.py", line 231, in _check_generic
raise TypeError(f"Too {'many' if alen > elen else 'few'} parameters for {cls};"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Too many parameters for typing.List[typing.Callable[~P, ~T]]; actual 3, expected 2
New changeset f92b913 by Serhiy Storchaka in branch 'main': bpo-44793: Fix checking the number of arguments when subscribe a generic type with ParamSpec parameter. (GH-27515) f92b913
New changeset c8db292 by Miss Islington (bot) in branch '3.10': bpo-44793: Fix checking the number of arguments when subscribe a generic type with ParamSpec parameter. (GH-27515) c8db292
Activity
serhiy-storchaka commentedon Jul 31, 2021
int substitutes P as [int], str substitutes T, and the third argument float is ignored.
serhiy-storchaka commentedon Jul 31, 2021
If Callable is nested, it works as expected:
collections.abc.Callable raises an error too.
serhiy-storchaka commentedon Jul 31, 2021
There is also similar bug in Generic:
serhiy-storchaka commentedon Aug 2, 2021
New changeset f92b913 by Serhiy Storchaka in branch 'main':
bpo-44793: Fix checking the number of arguments when subscribe a generic type with ParamSpec parameter. (GH-27515)
f92b913
miss-islington commentedon Aug 2, 2021
New changeset c8db292 by Miss Islington (bot) in branch '3.10':
bpo-44793: Fix checking the number of arguments when subscribe a generic type with ParamSpec parameter. (GH-27515)
c8db292