You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
array.array should support __class_getitem__ #98658
The array.array class has been marked as generic in typeshed since 2017 (python/typeshed#1649). We just got a report on mypy (python/mypy#13942) pointing out that the class is not subscriptable at runtime. Just like other generic standard library classes, we should make array.array subscriptable at runtime (PEP-585).
Activity
pythongh-98658: Add __class_getitem__ to array.array
serhiy-storchaka commentedon Oct 26, 2022
Isn't it a bug in typeshed? This class does not look generic.
JelleZijlstra commentedon Oct 27, 2022
It's marked as generic because the "element" type depends on the type code:
So we'd want
a1to be typed as anarray[int]anda2as anarray[float].serhiy-storchaka commentedon Oct 27, 2022
It makes sense.
pythongh-98658: Add __class_getitem__ to array.array (python#98661)