Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

improve `ndarray.__getitem__` with rank-typing

Open
#557 2 comments 0 reactions 1 assignee View on GitHub

@jorenham is already working on this.

Since May 15, 2025.

Assessment

This issue has not been assessed yet.

Description

numpy.ndarray stubs: Enhancement topic: shape-typing

It's a very complicated method signature, e.g.

  • _[()] returns Self if 1d+, otherwise (if 0d) returns its scalar type
  • _[int] returns Self[DTypeT, ShapeT[1:]] if 1d+, otherwise (if 0d) returns its scalar type
  • _[int, int] returns Self[DTypeT, ShapeT[1:]] if 1d+, otherwise (if 0d) returns its scalar type
  • ...
  • _[None] returns array[DTypeT, (int, *ShapeT)]
  • _[None, None] returns array[DTypeT, (int, int, *ShapeT)]
  • ...
  • _[slice | array-indexer] returns Self for 1d+, otherwise rejects
  • _[slice | array-indexer, slice | array-indexer] returns Self for 2d+, otherwise rejects
  • ...
  • _[...] returns Self for 0d+

almost all possible combinations are also valid 😅

Dominant language
Python
Stars
79
Forks
8
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from numpy/numtype

All issues in numpy/numtype

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.