Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
There is a difference between PR 19836 and the typing module in handling nested unsubscribed generic aliases: >>> from typing import * >>> T = TypeVar('T') >>> D1 = Dict[T, List] >>> D2 = dict[T, List] >>> D1.__parameters__ (~T,) >>> D1[int] typing.Dict[int, typing.List[~T]] >>> D1[int].__parameters__ (~T,) >>> D1[int][str] typing.Dict[int, typing.List[str]] >>> D1[int, str] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/serhiy/py/cpython/Lib/typing.py", line 267, in inner return func(*args, **kwds) File "/home/serhiy/py/cpython/Lib/typing.py", line 686, in __getitem__ _check_generic(self, params) File "/home/serhiy/py/cpython/Lib/typing.py", line 221, in _check_generic raise TypeError(f"Too {'many' if alen > elen else 'few'} parameters for {cls};" TypeError: Too many parameters for typing.Dict[~T, typing.List]; actual 2, expected 1 >>> D2.__parameters__ (~T, ~T) >>> D2[int] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Too few arguments for dict[~T, typing.List] >>> D2[int, str] dict[int, typing.List[str]] But this behavior is not specified and is not covered by tests. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40408> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com