Message412464
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. |
|
Date |
User |
Action |
Args |
2022-02-03 20:23:24 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, JelleZijlstra, kj |
2022-02-03 20:23:24 | serhiy.storchaka | set | messageid: <1643919804.18.0.403733186197.issue44796@roundup.psfhosted.org> |
2022-02-03 20:23:24 | serhiy.storchaka | link | issue44796 messages |
2022-02-03 20:23:24 | serhiy.storchaka | create | |
|