8000 ENH: Add `__class_getitem__` to `ndarray`, `dtype` and `number` by BvB93 · Pull Request #19879 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add __class_getitem__ to ndarray, dtype and number #19879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 25, 2021
Prev Previous commit
Next Next commit
DOC: Add a release note for __class_getitem__
  • Loading branch information
Bas van Beek committed Sep 15, 2021
commit 49f53580e23bcf7dc305d97678125b34e1cff0cb
15 changes: 15 additions & 0 deletions doc/release/upcoming_changes/19879.new_feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
``ndarray``, ``dtype`` and ``number`` are now runtime-subscriptable
-------------------------------------------------------------------
Mimicking :pep:`585`, the `~numpy.ndarray`, `~numpy.dtype` and `~numpy.number`
classes are now subscriptable for python 3.9 and later.
Consequently, expressions that were previously only allowed in .pyi stub files
or with the help of ``from __future__ import annotations`` are now also legal
during runtime.

.. code-block:: python

>>> import numpy as np
>>> from typing import Any

>>> np.ndarray[Any, np.dtype[np.float64]]
numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
0