GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — array.array should support `__class_getitem__` · Issue #98658 · python/cpython

array.array should support __class_getitem__ #98658

New issue
Copy link
New issue
Copy link
Closed
Closed
array.array should support __class_getitem__#98658
Copy link
Labels
topic-typingtype-featureA feature request or enhancementA feature request or enhancement

Description

@JelleZijlstra
JelleZijlstra
opened on Oct 25, 2022
Issue body actions

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).

I'll make a PR.

Reacted by Alex Waygood, Stefano Gogioso, LeeeeT, Oliver Wilkes and Vamshee Teja

Activity

  1. JelleZijlstra
    added
    type-featureA feature request or enhancementA feature request or enhancement
    topic-typing
    on Oct 25, 2022
  2. JelleZijlstra
    added a commit that references this issue on Oct 25, 2022

    pythongh-98658: Add __class_getitem__ to array.array

    b41bf73
  3. serhiy-storchaka commented on Oct 26, 2022

    @serhiy-storchaka
    serhiy-storchaka
    on Oct 26, 2022
    Member
    More actions

    Isn't it a bug in typeshed? This class does not look generic.

  4. JelleZijlstra commented on Oct 27, 2022

    @JelleZijlstra
    JelleZijlstra
    on Oct 27, 2022
    MemberAuthor
    More actions

    It's marked as generic because the "element" type depends on the type code:

    In [50]: a1=array.array('b', [1])
    
    In [51]: a1[0]
    Out[51]: 1
    
    In [52]: a2 = array.array('f', [1])
    
    In [53]: a2[0]
    Out[53]: 1.0
    

    So we'd want a1 to be typed as an array[int] and a2 as an array[float].

  5. serhiy-storchaka commented on Oct 27, 2022

    @serhiy-storchaka
    serhiy-storchaka
    on Oct 27, 2022
    Member
    More actions

    It makes sense.

  6. JelleZijlstra
    closed this as completedin 5cf317aon Nov 1, 2022
  7. serhiy-storchaka
    added this to Struct, memoryview and array issues 🏗️on Jul 13, 2026
  8. github-project-automation
    moved this from Todo to Done in Struct, memoryview and array issues 🏗️on Jul 13, 2026
  9. github-project-automation
    moved this to Todo in Struct, memoryview and array issues 🏗️on Jul 13, 2026
  10. serhiy-storchaka
    added a commit that references this issue on Aug 9, 2026

    pythongh-98658: Add __class_getitem__ to array.array (python#98661)

    5cf317a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-typingtype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • Struct, memoryview and array issues 🏗️
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.