This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients gvanrossum, levkivskyi, serhiy.storchaka
Date 2020-05-02.18:03:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588442620.22.0.102911863717.issue40408@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-05-02 18:03:40serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, levkivskyi
2020-05-02 18:03:40serhiy.storchakasetmessageid: <1588442620.22.0.102911863717.issue40408@roundup.psfhosted.org>
2020-05-02 18:03:40serhiy.storchakalinkissue40408 messages
2020-05-02 18:03:40serhiy.storchakacreate