[issue44793] Arguments ignored in substitution in typing.Callable

Serhiy Storchaka report at bugs.python.org
Sat Jul 31 12:52:30 EDT 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

If Callable is nested, it works as expected:

>>> 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

collections.abc.Callable raises an error too.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44793>
_______________________________________


More information about the Python-bugs-list mailing list