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 JelleZijlstra, gvanrossum, kj, serhiy.storchaka
Date 2022-02-03.20:23:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643919804.18.0.403733186197.issue44796@roundup.psfhosted.org>
In-reply-to
Content
It does not have a use case of T[int] in mind. It is an implementation detail which simplifies the code, makes runtime checks more strict and makes types.GenericAlias more similar to typing._GenericAlias.

For example, currently:

>>> A = List[T]
>>> B = list[T]
>>> A[None]
typing.List[NoneType]
>>> B[None]
list[None]
>>> A['X']
typing.List[ForwardRef('X')]
>>> B['X']
list['X']

With the proposed change:

>>> B[None]
list[NoneType]
>>> B['X']
list[ForwardRef('X')]

Meanless expressions like A[42], A[Final], A[Final[int]], A[ClassVar], A[ClassVar[int]], etc which are silently accepted will now be errors.

The code simplification (especially for the C code) is my primary goal, and the rest is a nice side effect. It is possible to add more strict runtime checks and conversions without making TypeVar and ParamSpec subscriptable, but the code will not be so simple.
History
Date User Action Args
2022-02-03 20:23:24serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, JelleZijlstra, kj
2022-02-03 20:23:24serhiy.storchakasetmessageid: <1643919804.18.0.403733186197.issue44796@roundup.psfhosted.org>
2022-02-03 20:23:24serhiy.storchakalinkissue44796 messages
2022-02-03 20:23:24serhiy.storchakacreate