summaryrefslogtreecommitdiff
path: root/numpy/typing
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2020-10-21 15:50:50 +0300
committerGitHub <noreply@github.com>2020-10-21 15:50:50 +0300
commitebc57e109fc7ece660311346919ef6db794398c1 (patch)
tree997513038f3f60ca10fec6ae3307f4bc4f3e3910 /numpy/typing
parent32f1359fc2d11014b240dee2270acea1784a34bb (diff)
parentcd15084bf9f21f4e255f9c788f903ffcbf703a58 (diff)
downloadnumpy-ebc57e109fc7ece660311346919ef6db794398c1.tar.gz
Merge pull request #17540 from BvB93/precision
ENH: Make `np.number` generic with respect to its precision
Diffstat (limited to 'numpy/typing')
-rw-r--r--numpy/typing/__init__.py82
-rw-r--r--numpy/typing/_callable.py116
-rw-r--r--numpy/typing/tests/data/fail/bitwise_ops.py4
-rw-r--r--numpy/typing/tests/data/fail/numerictypes.py2
-rw-r--r--numpy/typing/tests/data/fail/scalars.py4
-rw-r--r--numpy/typing/tests/data/reveal/arithmetic.py332
-rw-r--r--numpy/typing/tests/data/reveal/array_constructors.py2
-rw-r--r--numpy/typing/tests/data/reveal/bitwise_ops.py206
-rw-r--r--numpy/typing/tests/data/reveal/dtype.py20
-rw-r--r--numpy/typing/tests/data/reveal/fromnumeric.py194
-rw-r--r--numpy/typing/tests/data/reveal/nbit_base_example.py18
-rw-r--r--numpy/typing/tests/data/reveal/ndarray_misc.py94
-rw-r--r--numpy/typing/tests/data/reveal/scalars.py12
-rw-r--r--numpy/typing/tests/test_typing.py5
14 files changed, 622 insertions, 469 deletions
diff --git a/numpy/typing/__init__.py b/numpy/typing/__init__.py
index dafabd95a..2738da071 100644
--- a/numpy/typing/__init__.py
+++ b/numpy/typing/__init__.py
@@ -89,7 +89,89 @@ Although this is valid Numpy code, the type checker will complain about it,
since its usage is discouraged.
Please see : https://numpy.org/devdocs/reference/arrays.dtypes.html
+NBitBase
+~~~~~~~~
+
+.. autoclass:: numpy.typing.NBitBase
+
"""
+
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ import sys
+ if sys.version_info >= (3, 8):
+ from typing import final
+ else:
+ from typing_extensions import final
+else:
+ def final(f): return f
+
+
+@final # Dissallow the creation of arbitrary `NBitBase` subclasses
+class NBitBase:
+ """
+ An object representing `numpy.number` precision during static type checking.
+
+ Used exclusively for the purpose static type checking, `NBitBase`
+ represents the base of a hierachieral set of subclasses.
+ Each subsequent subclass is herein used for representing a lower level
+ of precision, *e.g.* ``64Bit > 32Bit > 16Bit``.
+
+ Examples
+ --------
+ Below is a typical usage example: `NBitBase` is herein used for annotating a
+ function that takes a float and integer of arbitrary precision as arguments
+ and returns a new float of whichever precision is largest
+ (*e.g.* ``np.float16 + np.int64 -> np.float64``).
+
+ .. code-block:: python
+
+ >>> from typing import TypeVar, TYPE_CHECKING
+ >>> import numpy as np
+ >>> import numpy.typing as npt
+
+ >>> T = TypeVar("T", bound=npt.NBitBase)
+
+ >>> def add(a: "np.floating[T]", b: "np.integer[T]") -> "np.floating[T]":
+ ... return a + b
+
+ >>> a = np.float16()
+ >>> b = np.int64()
+ >>> out = add(a, b)
+
+ >>> if TYPE_CHECKING:
+ ... reveal_locals()
+ ... # note: Revealed local types are:
+ ... # note: a: numpy.floating[numpy.typing._16Bit*]
+ ... # note: b: numpy.signedinteger[numpy.typing._64Bit*]
+ ... # note: out: numpy.floating[numpy.typing._64Bit*]
+
+ """
+
+ def __init_subclass__(cls) -> None:
+ allowed_names = {
+ "NBitBase", "_256Bit", "_128Bit", "_96Bit", "_80Bit",
+ "_64Bit", "_32Bit", "_16Bit", "_8Bit",
+ }
+ if cls.__name__ not in allowed_names:
+ raise TypeError('cannot inherit from final class "NBitBase"')
+ super().__init_subclass__()
+
+
+# Silence errors about subclassing a `@final`-decorated class
+class _256Bit(NBitBase): ... # type: ignore[misc]
+class _128Bit(_256Bit): ... # type: ignore[misc]
+class _96Bit(_128Bit): ... # type: ignore[misc]
+class _80Bit(_96Bit): ... # type: ignore[misc]
+class _64Bit(_80Bit): ... # type: ignore[misc]
+class _32Bit(_64Bit): ... # type: ignore[misc]
+class _16Bit(_32Bit): ... # type: ignore[misc]
+class _8Bit(_16Bit): ... # type: ignore[misc]
+
+# Clean up the namespace
+del TYPE_CHECKING, final
+
from ._scalars import (
_CharLike,
_BoolLike,
diff --git a/numpy/typing/_callable.py b/numpy/typing/_callable.py
index 7c2ee86cb..b16891b0e 100644
--- a/numpy/typing/_callable.py
+++ b/numpy/typing/_callable.py
@@ -9,7 +9,7 @@ See the `Mypy documentation`_ on protocols for more details.
"""
import sys
-from typing import Union, TypeVar, overload, Any
+from typing import Union, TypeVar, overload, Any, TYPE_CHECKING, NoReturn
from numpy import (
generic,
@@ -25,6 +25,7 @@ from numpy import (
float32,
float64,
complexfloating,
+ complex64,
complex128,
)
from ._scalars import (
@@ -34,6 +35,7 @@ from ._scalars import (
_ComplexLike,
_NumberLike,
)
+from . import NBitBase
if sys.version_info >= (3, 8):
from typing import Protocol
@@ -46,7 +48,9 @@ else:
else:
HAVE_PROTOCOL = True
-if HAVE_PROTOCOL:
+if TYPE_CHECKING or HAVE_PROTOCOL:
+ _NBit_co = TypeVar("_NBit_co", covariant=True, bound=NBitBase)
+ _NBit = TypeVar("_NBit", bound=NBitBase)
_IntType = TypeVar("_IntType", bound=integer)
_NumberType = TypeVar("_NumberType", bound=number)
_NumberType_co = TypeVar("_NumberType_co", covariant=True, bound=number)
@@ -56,7 +60,7 @@ if HAVE_PROTOCOL:
@overload
def __call__(self, __other: _BoolLike) -> _GenericType_co: ...
@overload # platform dependent
- def __call__(self, __other: int) -> Union[int32, int64]: ...
+ def __call__(self, __other: int) -> signedinteger[Any]: ...
@overload
def __call__(self, __other: float) -> float64: ...
@overload
@@ -68,14 +72,16 @@ if HAVE_PROTOCOL:
@overload
def __call__(self, __other: _BoolLike) -> _GenericType_co: ...
@overload # platform dependent
- def __call__(self, __other: int) -> Union[int32, int64]: ...
+ def __call__(self, __other: int) -> signedinteger[Any]: ...
@overload
def __call__(self, __other: _IntType) -> _IntType: ...
class _BoolSub(Protocol):
# Note that `__other: bool_` is absent here
+ @overload
+ def __call__(self, __other: bool) -> NoReturn: ...
@overload # platform dependent
- def __call__(self, __other: int) -> Union[int32, int64]: ...
+ def __call__(self, __other: int) -> signedinteger[Any]: ...
@overload
def __call__(self, __other: float) -> float64: ...
@overload
@@ -97,51 +103,101 @@ if HAVE_PROTOCOL:
@overload
def __call__(self, __other: _FloatLike) -> timedelta64: ...
- class _IntTrueDiv(Protocol):
+ class _IntTrueDiv(Protocol[_NBit_co]):
+ @overload
+ def __call__(self, __other: bool) -> floating[_NBit_co]: ...
@overload
- def __call__(self, __other: Union[_IntLike, float]) -> floating: ...
+ def __call__(self, __other: int) -> floating[Any]: ...
+ @overload
+ def __call__(self, __other: float) -> float64: ...
@overload
- def __call__(self, __other: complex) -> complexfloating[floating]: ...
+ def __call__(self, __other: complex) -> complex128: ...
+ @overload
+ def __call__(self, __other: integer[_NBit]) -> floating[Union[_NBit_co, _NBit]]: ...
- class _UnsignedIntOp(Protocol):
+ class _UnsignedIntOp(Protocol[_NBit_co]):
# NOTE: `uint64 + signedinteger -> float64`
@overload
- def __call__(self, __other: Union[bool, unsignedinteger]) -> unsignedinteger: ...
+ def __call__(self, __other: bool) -> unsignedinteger[_NBit_co]: ...
+ @overload
+ def __call__(
+ self, __other: Union[int, signedinteger[Any]]
+ ) -> Union[signedinteger[Any], float64]: ...
@overload
- def __call__(self, __other: Union[int, signedinteger]) -> Union[signedinteger, float64]: ...
+ def __call__(self, __other: float) -> float64: ...
@overload
- def __call__(self, __other: float) -> floating: ...
+ def __call__(self, __other: complex) -> complex128: ...
@overload
- def __call__(self, __other: complex) -> complexfloating[floating]: ...
+ def __call__(
+ self, __other: unsignedinteger[_NBit]
+ ) -> unsignedinteger[Union[_NBit_co, _NBit]]: ...
- class _UnsignedIntBitOp(Protocol):
- # TODO: The likes of `uint64 | np.signedinteger` will fail as there
- # is no signed integer type large enough to hold a `uint64`
- # See https://github.com/numpy/numpy/issues/2524
+ class _UnsignedIntBitOp(Protocol[_NBit_co]):
+ @overload
+ def __call__(self, __other: bool) -> unsignedinteger[_NBit_co]: ...
+ @overload
+ def __call__(self, __other: int) -> signedinteger[Any]: ...
@overload
- def __call__(self, __other: Union[bool, unsignedinteger]) -> unsignedinteger: ...
+ def __call__(self, __other: signedinteger[Any]) -> signedinteger[Any]: ...
@overload
- def __call__(self, __other: Union[int, signedinteger]) -> signedinteger: ...
+ def __call__(
+ self, __other: unsignedinteger[_NBit]
+ ) -> unsignedinteger[Union[_NBit_co, _NBit]]: ...
- class _SignedIntOp(Protocol):
+ class _SignedIntOp(Protocol[_NBit_co]):
@overload
- def __call__(self, __other: Union[int, signedinteger]) -> signedinteger: ...
+ def __call__(self, __other: bool) -> signedinteger[_NBit_co]: ...
@overload
- def __call__(self, __other: float) -> floating: ...
+ def __call__(self, __other: int) -> signedinteger[Any]: ...
@overload
- def __call__(self, __other: complex) -> complexfloating[floating]: ...
+ def __call__(self, __other: float) -> float64: ...
+ @overload
+ def __call__(self, __other: complex) -> complex128: ...
+ @overload
+ def __call__(
+ self, __other: signedinteger[_NBit]
+ ) -> signedinteger[Union[_NBit_co, _NBit]]: ...
- class _SignedIntBitOp(Protocol):
- def __call__(self, __other: Union[int, signedinteger]) -> signedinteger: ...
+ class _SignedIntBitOp(Protocol[_NBit_co]):
+ @overload
+ def __call__(self, __other: bool) -> signedinteger[_NBit_co]: ...
+ @overload
+ def __call__(self, __other: int) -> signedinteger[Any]: ...
+ @overload
+ def __call__(
+ self, __other: signedinteger[_NBit]
+ ) -> signedinteger[Union[_NBit_co, _NBit]]: ...
- class _FloatOp(Protocol):
+ class _FloatOp(Protocol[_NBit_co]):
@overload
- def __call__(self, __other: _FloatLike) -> floating: ...
+ def __call__(self, __other: bool) -> floating[_NBit_co]: ...
+ @overload
+ def __call__(self, __other: int) -> floating[Any]: ...
+ @overload
+ def __call__(self, __other: float) -> float64: ...
@overload
- def __call__(self, __other: complex) -> complexfloating[floating]: ...
+ def __call__(self, __other: complex) -> complex128: ...
+ @overload
+ def __call__(
+ self, __other: Union[integer[_NBit], floating[_NBit]]
+ ) -> floating[Union[_NBit_co, _NBit]]: ...
- class _ComplexOp(Protocol):
- def __call__(self, __other: _ComplexLike) -> complexfloating[floating]: ...
+ class _ComplexOp(Protocol[_NBit_co]):
+ @overload
+ def __call__(self, __other: bool) -> complexfloating[_NBit_co, _NBit_co]: ...
+ @overload
+ def __call__(self, __other: int) -> complexfloating[Any, Any]: ...
+ @overload
+ def __call__(self, __other: Union[float, complex]) -> complex128: ...
+ @overload
+ def __call__(
+ self,
+ __other: Union[
+ integer[_NBit],
+ floating[_NBit],
+ complexfloating[_NBit, _NBit],
+ ]
+ ) -> complexfloating[Union[_NBit_co, _NBit], Union[_NBit_co, _NBit]]: ...
class _NumberOp(Protocol):
def __call__(self, __other: _NumberLike) -> number: ...
diff --git a/numpy/typing/tests/data/fail/bitwise_ops.py b/numpy/typing/tests/data/fail/bitwise_ops.py
index 3b5be95c0..8a8f89755 100644
--- a/numpy/typing/tests/data/fail/bitwise_ops.py
+++ b/numpy/typing/tests/data/fail/bitwise_ops.py
@@ -9,9 +9,9 @@ i = int()
f8 = np.float64()
b_ >> f8 # E: No overload variant
-i8 << f8 # E: incompatible type
+i8 << f8 # E: No overload variant
i | f8 # E: Unsupported operand types
-i8 ^ f8 # E: incompatible type
+i8 ^ f8 # E: No overload variant
u8 & f8 # E: No overload variant
~f8 # E: Unsupported operand type
diff --git a/numpy/typing/tests/data/fail/numerictypes.py b/numpy/typing/tests/data/fail/numerictypes.py
index dd03eacc1..94537a23b 100644
--- a/numpy/typing/tests/data/fail/numerictypes.py
+++ b/numpy/typing/tests/data/fail/numerictypes.py
@@ -10,4 +10,4 @@ np.issubsctype(1, np.int64) # E: incompatible type "int"
np.issubdtype(1, np.int64) # E: incompatible type "int"
-np.find_common_type(np.int64, np.int64) # E: incompatible type "Type[int64]"
+np.find_common_type(np.int64, np.int64) # E: incompatible type "Type[signedinteger[Any]]"
diff --git a/numpy/typing/tests/data/fail/scalars.py b/numpy/typing/tests/data/fail/scalars.py
index 13bb45483..e7c4c7485 100644
--- a/numpy/typing/tests/data/fail/scalars.py
+++ b/numpy/typing/tests/data/fail/scalars.py
@@ -47,11 +47,7 @@ np.void("test") # E: incompatible type
np.generic(1) # E: Cannot instantiate abstract class
np.number(1) # E: Cannot instantiate abstract class
np.integer(1) # E: Cannot instantiate abstract class
-np.signedinteger(1) # E: Cannot instantiate abstract class
-np.unsignedinteger(1) # E: Cannot instantiate abstract class
np.inexact(1) # E: Cannot instantiate abstract class
-np.floating(1) # E: Cannot instantiate abstract class
-np.complexfloating(1) # E: Cannot instantiate abstract class
np.character("test") # E: Cannot instantiate abstract class
np.flexible(b"test") # E: Cannot instantiate abstract class
diff --git a/numpy/typing/tests/data/reveal/arithmetic.py b/numpy/typing/tests/data/reveal/arithmetic.py
index b8c457aaf..a1290304a 100644
--- a/numpy/typing/tests/data/reveal/arithmetic.py
+++ b/numpy/typing/tests/data/reveal/arithmetic.py
@@ -45,212 +45,212 @@ reveal_type(td - i8) # E: numpy.timedelta64
reveal_type(td / f) # E: numpy.timedelta64
reveal_type(td / f4) # E: numpy.timedelta64
reveal_type(td / f8) # E: numpy.timedelta64
-reveal_type(td / td) # E: float64
-reveal_type(td // td) # E: signedinteger
+reveal_type(td / td) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(td // td) # E: numpy.signedinteger[numpy.typing._64Bit]
reveal_type(td % td) # E: numpy.timedelta64
# boolean
-reveal_type(b_ / b) # E: float64
-reveal_type(b_ / b_) # E: float64
-reveal_type(b_ / i) # E: float64
-reveal_type(b_ / i8) # E: float64
-reveal_type(b_ / i4) # E: float64
-reveal_type(b_ / u8) # E: float64
-reveal_type(b_ / u4) # E: float64
-reveal_type(b_ / f) # E: float64
-reveal_type(b_ / f8) # E: float64
-reveal_type(b_ / f4) # E: float32
-reveal_type(b_ / c) # E: complex128
-reveal_type(b_ / c16) # E: complex128
-reveal_type(b_ / c8) # E: complex64
+reveal_type(b_ / b) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / i) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / i8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / i4) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / u8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / u4) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / f) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / f4) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(b_ / c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(b_ / c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(b_ / c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(b / b_) # E: float64
-reveal_type(b_ / b_) # E: float64
-reveal_type(i / b_) # E: float64
-reveal_type(i8 / b_) # E: float64
-reveal_type(i4 / b_) # E: float64
-reveal_type(u8 / b_) # E: float64
-reveal_type(u4 / b_) # E: float64
-reveal_type(f / b_) # E: float64
-reveal_type(f8 / b_) # E: float64
-reveal_type(f4 / b_) # E: float32
-reveal_type(c / b_) # E: complex128
-reveal_type(c16 / b_) # E: complex128
-reveal_type(c8 / b_) # E: complex64
+reveal_type(b / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i8 / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i4 / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(u8 / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(u4 / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8 / b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f4 / b_) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(c / b_) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 / b_) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c8 / b_) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
# Complex
-reveal_type(c16 + c16) # E: complexfloating
-reveal_type(c16 + f8) # E: complexfloating
-reveal_type(c16 + i8) # E: complexfloating
-reveal_type(c16 + c8) # E: complexfloating
-reveal_type(c16 + f4) # E: complexfloating
-reveal_type(c16 + i4) # E: complexfloating
-reveal_type(c16 + b_) # E: complex128
-reveal_type(c16 + b) # E: complexfloating
-reveal_type(c16 + c) # E: complexfloating
-reveal_type(c16 + f) # E: complexfloating
-reveal_type(c16 + i) # E: complexfloating
+reveal_type(c16 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + f8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + i8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + f4) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + i4) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + b_) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + b) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + f) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c16 + i) # E: numpy.complexfloating[Any, Any]
reveal_type(c16 + AR) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(c16 + c16) # E: complexfloating
-reveal_type(f8 + c16) # E: complexfloating
-reveal_type(i8 + c16) # E: complexfloating
-reveal_type(c8 + c16) # E: complexfloating
-reveal_type(f4 + c16) # E: complexfloating
-reveal_type(i4 + c16) # E: complexfloating
-reveal_type(b_ + c16) # E: complex128
-reveal_type(b + c16) # E: complexfloating
-reveal_type(c + c16) # E: complexfloating
-reveal_type(f + c16) # E: complexfloating
-reveal_type(i + c16) # E: complexfloating
+reveal_type(c16 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f8 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(i8 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c8 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f4 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(i4 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(b_ + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(b + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(i + c16) # E: numpy.complexfloating[Any, Any]
reveal_type(AR + c16) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(c8 + c16) # E: complexfloating
-reveal_type(c8 + f8) # E: complexfloating
-reveal_type(c8 + i8) # E: complexfloating
-reveal_type(c8 + c8) # E: complexfloating
-reveal_type(c8 + f4) # E: complexfloating
-reveal_type(c8 + i4) # E: complexfloating
-reveal_type(c8 + b_) # E: complex64
-reveal_type(c8 + b) # E: complexfloating
-reveal_type(c8 + c) # E: complexfloating
-reveal_type(c8 + f) # E: complexfloating
-reveal_type(c8 + i) # E: complexfloating
+reveal_type(c8 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c8 + f8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c8 + i8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c8 + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(c8 + f4) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(c8 + i4) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(c8 + b_) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(c8 + b) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(c8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c8 + f) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c8 + i) # E: numpy.complexfloating[Any, Any]
reveal_type(c8 + AR) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(c16 + c8) # E: complexfloating
-reveal_type(f8 + c8) # E: complexfloating
-reveal_type(i8 + c8) # E: complexfloating
-reveal_type(c8 + c8) # E: complexfloating
-reveal_type(f4 + c8) # E: complexfloating
-reveal_type(i4 + c8) # E: complexfloating
-reveal_type(b_ + c8) # E: complex64
-reveal_type(b + c8) # E: complexfloating
-reveal_type(c + c8) # E: complexfloating
-reveal_type(f + c8) # E: complexfloating
-reveal_type(i + c8) # E: complexfloating
+reveal_type(c16 + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f8 + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(i8 + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(c8 + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(f4 + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(i4 + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(b_ + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(b + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(c + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(i + c8) # E: numpy.complexfloating[Any, Any]
reveal_type(AR + c8) # E: Union[numpy.ndarray, numpy.generic]
# Float
-reveal_type(f8 + f8) # E: floating
-reveal_type(f8 + i8) # E: floating
-reveal_type(f8 + f4) # E: floating
-reveal_type(f8 + i4) # E: floating
-reveal_type(f8 + b_) # E: float64
-reveal_type(f8 + b) # E: floating
-reveal_type(f8 + c) # E: complexfloating
-reveal_type(f8 + f) # E: floating
-reveal_type(f8 + i) # E: floating
+reveal_type(f8 + f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8 + i8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8 + f4) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8 + i4) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8 + b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8 + b) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f8 + f) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8 + i) # E: numpy.floating[Any]
reveal_type(f8 + AR) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(f8 + f8) # E: floating
-reveal_type(i8 + f8) # E: floating
-reveal_type(f4 + f8) # E: floating
-reveal_type(i4 + f8) # E: floating
-reveal_type(b_ + f8) # E: float64
-reveal_type(b + f8) # E: floating
-reveal_type(c + f8) # E: complexfloating
-reveal_type(f + f8) # E: floating
-reveal_type(i + f8) # E: floating
+reveal_type(f8 + f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i8 + f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f4 + f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i4 + f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ + f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b + f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(c + f8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f + f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i + f8) # E: numpy.floating[Any]
reveal_type(AR + f8) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(f4 + f8) # E: floating
-reveal_type(f4 + i8) # E: floating
-reveal_type(f4 + f4) # E: floating
-reveal_type(f4 + i4) # E: floating
-reveal_type(f4 + b_) # E: float32
-reveal_type(f4 + b) # E: floating
-reveal_type(f4 + c) # E: complexfloating
-reveal_type(f4 + f) # E: floating
-reveal_type(f4 + i) # E: floating
+reveal_type(f4 + f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f4 + i8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f4 + f4) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(f4 + i4) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(f4 + b_) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(f4 + b) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(f4 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f4 + f) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f4 + i) # E: numpy.floating[Any]
reveal_type(f4 + AR) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(f8 + f4) # E: floating
-reveal_type(i8 + f4) # E: floating
-reveal_type(f4 + f4) # E: floating
-reveal_type(i4 + f4) # E: floating
-reveal_type(b_ + f4) # E: float32
-reveal_type(b + f4) # E: floating
-reveal_type(c + f4) # E: complexfloating
-reveal_type(f + f4) # E: floating
-reveal_type(i + f4) # E: floating
+reveal_type(f8 + f4) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i8 + f4) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f4 + f4) # E: umpy.floating[numpy.typing._32Bit]
+reveal_type(i4 + f4) # E: umpy.floating[numpy.typing._32Bit]
+reveal_type(b_ + f4) # E: umpy.floating[numpy.typing._32Bit]
+reveal_type(b + f4) # E: umpy.floating[numpy.typing._32Bit]
+reveal_type(c + f4) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f + f4) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i + f4) # E: numpy.floating[Any]
reveal_type(AR + f4) # E: Union[numpy.ndarray, numpy.generic]
# Int
-reveal_type(i8 + i8) # E: signedinteger
-reveal_type(i8 + u8) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(i8 + i4) # E: signedinteger
-reveal_type(i8 + u4) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(i8 + b_) # E: int64
-reveal_type(i8 + b) # E: signedinteger
-reveal_type(i8 + c) # E: complexfloating
-reveal_type(i8 + f) # E: floating
-reveal_type(i8 + i) # E: signedinteger
+reveal_type(i8 + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 + u8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(i8 + i4) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(i8 + b_) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 + b) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(i8 + f) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i8 + i) # E: numpy.signedinteger[Any]
reveal_type(i8 + AR) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(u8 + u8) # E: unsignedinteger
-reveal_type(u8 + i4) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(u8 + u4) # E: unsignedinteger
-reveal_type(u8 + b_) # E: uint64
-reveal_type(u8 + b) # E: unsignedinteger
-reveal_type(u8 + c) # E: complexfloating
-reveal_type(u8 + f) # E: floating
-reveal_type(u8 + i) # E: Union[numpy.signedinteger, numpy.float64]
+reveal_type(u8 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 + i4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(u8 + u4) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 + b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 + b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(u8 + f) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(u8 + i) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
reveal_type(u8 + AR) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(i8 + i8) # E: signedinteger
-reveal_type(u8 + i8) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(i4 + i8) # E: signedinteger
-reveal_type(u4 + i8) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(b_ + i8) # E: int64
-reveal_type(b + i8) # E: signedinteger
-reveal_type(c + i8) # E: complexfloating
-reveal_type(f + i8) # E: floating
-reveal_type(i + i8) # E: signedinteger
+reveal_type(i8 + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(u8 + i8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(i4 + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(u4 + i8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(b_ + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(b + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(c + i8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f + i8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i + i8) # E: numpy.signedinteger[Any]
reveal_type(AR + i8) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(u8 + u8) # E: unsignedinteger
-reveal_type(i4 + u8) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(u4 + u8) # E: unsignedinteger
-reveal_type(b_ + u8) # E: uint64
-reveal_type(b + u8) # E: unsignedinteger
-reveal_type(c + u8) # E: complexfloating
-reveal_type(f + u8) # E: floating
-reveal_type(i + u8) # E: Union[numpy.signedinteger, numpy.float64]
+reveal_type(u8 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(i4 + u8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(u4 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(b_ + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(b + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(c + u8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
+reveal_type(f + u8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(i + u8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
reveal_type(AR + u8) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(i4 + i8) # E: signedinteger
-reveal_type(i4 + i4) # E: signedinteger
-reveal_type(i4 + i) # E: signedinteger
-reveal_type(i4 + b_) # E: int32
-reveal_type(i4 + b) # E: signedinteger
+reveal_type(i4 + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i4 + i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(i4 + i) # E: numpy.signedinteger[Any]
+reveal_type(i4 + b_) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(i4 + b) # E: numpy.signedinteger[numpy.typing._32Bit]
reveal_type(i4 + AR) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(u4 + i8) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(u4 + i4) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(u4 + u8) # E: unsignedinteger
-reveal_type(u4 + u4) # E: unsignedinteger
-reveal_type(u4 + i) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(u4 + b_) # E: uint32
-reveal_type(u4 + b) # E: unsignedinteger
+reveal_type(u4 + i8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(u4 + i4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(u4 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u4 + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(u4 + i) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(u4 + b_) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(u4 + b) # E: numpy.unsignedinteger[numpy.typing._32Bit]
reveal_type(u4 + AR) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(i8 + i4) # E: signedinteger
-reveal_type(i4 + i4) # E: signedinteger
-reveal_type(i + i4) # E: signedinteger
-reveal_type(b_ + i4) # E: int32
-reveal_type(b + i4) # E: signedinteger
+reveal_type(i8 + i4) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i4 + i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(i + i4) # E: numpy.signedinteger[Any]
+reveal_type(b_ + i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(b + i4) # E: numpy.signedinteger[numpy.typing._32Bit]
reveal_type(AR + i4) # E: Union[numpy.ndarray, numpy.generic]
-reveal_type(i8 + u4) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(i4 + u4) # E: Union[numpy.signedinteger, numpy.float64]
-reveal_type(u8 + u4) # E: unsignedinteger
-reveal_type(u4 + u4) # E: unsignedinteger
-reveal_type(b_ + u4) # E: uint32
-reveal_type(b + u4) # E: unsignedinteger
-reveal_type(i + u4) # E: Union[numpy.signedinteger, numpy.float64]
+reveal_type(i8 + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(i4 + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(u8 + u4) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u4 + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(b_ + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(b + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(i + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
reveal_type(AR + u4) # E: Union[numpy.ndarray, numpy.generic]
diff --git a/numpy/typing/tests/data/reveal/array_constructors.py b/numpy/typing/tests/data/reveal/array_constructors.py
index ba8a8eda1..13a04777f 100644
--- a/numpy/typing/tests/data/reveal/array_constructors.py
+++ b/numpy/typing/tests/data/reveal/array_constructors.py
@@ -37,6 +37,6 @@ reveal_type(np.require(B, requirements="A")) # E: SubClass
reveal_type(np.require(C)) # E: ndarray
reveal_type(np.linspace(0, 10)) # E: numpy.ndarray
-reveal_type(np.linspace(0, 10, retstep=True)) # E: Tuple[numpy.ndarray, numpy.inexact]
+reveal_type(np.linspace(0, 10, retstep=True)) # E: Tuple[numpy.ndarray, numpy.inexact[Any]]
reveal_type(np.logspace(0, 10)) # E: numpy.ndarray
reveal_type(np.geomspace(1, 10)) # E: numpy.ndarray
diff --git a/numpy/typing/tests/data/reveal/bitwise_ops.py b/numpy/typing/tests/data/reveal/bitwise_ops.py
index ae899f47b..6883532f2 100644
--- a/numpy/typing/tests/data/reveal/bitwise_ops.py
+++ b/numpy/typing/tests/data/reveal/bitwise_ops.py
@@ -15,117 +15,117 @@ AR = np.array([0, 1, 2], dtype=np.int32)
AR.setflags(write=False)
-reveal_type(i8 << i8) # E: numpy.signedinteger
-reveal_type(i8 >> i8) # E: numpy.signedinteger
-reveal_type(i8 | i8) # E: numpy.signedinteger
-reveal_type(i8 ^ i8) # E: numpy.signedinteger
-reveal_type(i8 & i8) # E: numpy.signedinteger
-
-reveal_type(i8 << AR) # E: Union[numpy.ndarray, numpy.integer]
-reveal_type(i8 >> AR) # E: Union[numpy.ndarray, numpy.integer]
-reveal_type(i8 | AR) # E: Union[numpy.ndarray, numpy.integer, numpy.bool_]
-reveal_type(i8 ^ AR) # E: Union[numpy.ndarray, numpy.integer, numpy.bool_]
-reveal_type(i8 & AR) # E: Union[numpy.ndarray, numpy.integer, numpy.bool_]
-
-reveal_type(i4 << i4) # E: numpy.signedinteger
-reveal_type(i4 >> i4) # E: numpy.signedinteger
-reveal_type(i4 | i4) # E: numpy.signedinteger
-reveal_type(i4 ^ i4) # E: numpy.signedinteger
-reveal_type(i4 & i4) # E: numpy.signedinteger
-
-reveal_type(i8 << i4) # E: numpy.signedinteger
-reveal_type(i8 >> i4) # E: numpy.signedinteger
-reveal_type(i8 | i4) # E: numpy.signedinteger
-reveal_type(i8 ^ i4) # E: numpy.signedinteger
-reveal_type(i8 & i4) # E: numpy.signedinteger
-
-reveal_type(i8 << i) # E: numpy.signedinteger
-reveal_type(i8 >> i) # E: numpy.signedinteger
-reveal_type(i8 | i) # E: numpy.signedinteger
-reveal_type(i8 ^ i) # E: numpy.signedinteger
-reveal_type(i8 & i) # E: numpy.signedinteger
-
-reveal_type(i8 << b_) # E: numpy.int64
-reveal_type(i8 >> b_) # E: numpy.int64
-reveal_type(i8 | b_) # E: numpy.int64
-reveal_type(i8 ^ b_) # E: numpy.int64
-reveal_type(i8 & b_) # E: numpy.int64
-
-reveal_type(i8 << b) # E: numpy.signedinteger
-reveal_type(i8 >> b) # E: numpy.signedinteger
-reveal_type(i8 | b) # E: numpy.signedinteger
-reveal_type(i8 ^ b) # E: numpy.signedinteger
-reveal_type(i8 & b) # E: numpy.signedinteger
-
-reveal_type(u8 << u8) # E: numpy.unsignedinteger
-reveal_type(u8 >> u8) # E: numpy.unsignedinteger
-reveal_type(u8 | u8) # E: numpy.unsignedinteger
-reveal_type(u8 ^ u8) # E: numpy.unsignedinteger
-reveal_type(u8 & u8) # E: numpy.unsignedinteger
-
-reveal_type(u8 << AR) # E: Union[numpy.ndarray, numpy.integer]
-reveal_type(u8 >> AR) # E: Union[numpy.ndarray, numpy.integer]
-reveal_type(u8 | AR) # E: Union[numpy.ndarray, numpy.integer, numpy.bool_]
-reveal_type(u8 ^ AR) # E: Union[numpy.ndarray, numpy.integer, numpy.bool_]
-reveal_type(u8 & AR) # E: Union[numpy.ndarray, numpy.integer, numpy.bool_]
-
-reveal_type(u4 << u4) # E: numpy.unsignedinteger
-reveal_type(u4 >> u4) # E: numpy.unsignedinteger
-reveal_type(u4 | u4) # E: numpy.unsignedinteger
-reveal_type(u4 ^ u4) # E: numpy.unsignedinteger
-reveal_type(u4 & u4) # E: numpy.unsignedinteger
-
-reveal_type(u4 << i4) # E: numpy.signedinteger
-reveal_type(u4 >> i4) # E: numpy.signedinteger
-reveal_type(u4 | i4) # E: numpy.signedinteger
-reveal_type(u4 ^ i4) # E: numpy.signedinteger
-reveal_type(u4 & i4) # E: numpy.signedinteger
-
-reveal_type(u4 << i) # E: numpy.signedinteger
-reveal_type(u4 >> i) # E: numpy.signedinteger
-reveal_type(u4 | i) # E: numpy.signedinteger
-reveal_type(u4 ^ i) # E: numpy.signedinteger
-reveal_type(u4 & i) # E: numpy.signedinteger
-
-reveal_type(u8 << b_) # E: numpy.uint64
-reveal_type(u8 >> b_) # E: numpy.uint64
-reveal_type(u8 | b_) # E: numpy.uint64
-reveal_type(u8 ^ b_) # E: numpy.uint64
-reveal_type(u8 & b_) # E: numpy.uint64
-
-reveal_type(u8 << b) # E: numpy.unsignedinteger
-reveal_type(u8 >> b) # E: numpy.unsignedinteger
-reveal_type(u8 | b) # E: numpy.unsignedinteger
-reveal_type(u8 ^ b) # E: numpy.unsignedinteger
-reveal_type(u8 & b) # E: numpy.unsignedinteger
-
-reveal_type(b_ << b_) # E: numpy.int8
-reveal_type(b_ >> b_) # E: numpy.int8
+reveal_type(i8 << i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 >> i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 | i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 ^ i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 & i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+
+reveal_type(i8 << AR) # E: Union[numpy.ndarray, numpy.integer[Any]]
+reveal_type(i8 >> AR) # E: Union[numpy.ndarray, numpy.integer[Any]]
+reveal_type(i8 | AR) # E: Union[numpy.ndarray, numpy.integer[Any], numpy.bool_]
+reveal_type(i8 ^ AR) # E: Union[numpy.ndarray, numpy.integer[Any], numpy.bool_]
+reveal_type(i8 & AR) # E: Union[numpy.ndarray, numpy.integer[Any], numpy.bool_]
+
+reveal_type(i4 << i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(i4 >> i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(i4 | i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(i4 ^ i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(i4 & i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+
+reveal_type(i8 << i4) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 >> i4) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 | i4) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 ^ i4) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 & i4) # E: numpy.signedinteger[numpy.typing._64Bit]
+
+reveal_type(i8 << i) # E: numpy.signedinteger[Any]
+reveal_type(i8 >> i) # E: numpy.signedinteger[Any]
+reveal_type(i8 | i) # E: numpy.signedinteger[Any]
+reveal_type(i8 ^ i) # E: numpy.signedinteger[Any]
+reveal_type(i8 & i) # E: numpy.signedinteger[Any]
+
+reveal_type(i8 << b_) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 >> b_) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 | b_) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 ^ b_) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 & b_) # E: numpy.signedinteger[numpy.typing._64Bit]
+
+reveal_type(i8 << b) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 >> b) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 | b) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 ^ b) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 & b) # E: numpy.signedinteger[numpy.typing._64Bit]
+
+reveal_type(u8 << u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 >> u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 | u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 ^ u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 & u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+
+reveal_type(u8 << AR) # E: Union[numpy.ndarray, numpy.integer[Any]]
+reveal_type(u8 >> AR) # E: Union[numpy.ndarray, numpy.integer[Any]]
+reveal_type(u8 | AR) # E: Union[numpy.ndarray, numpy.integer[Any], numpy.bool_]
+reveal_type(u8 ^ AR) # E: Union[numpy.ndarray, numpy.integer[Any], numpy.bool_]
+reveal_type(u8 & AR) # E: Union[numpy.ndarray, numpy.integer[Any], numpy.bool_]
+
+reveal_type(u4 << u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(u4 >> u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(u4 | u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(u4 ^ u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(u4 & u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+
+reveal_type(u4 << i4) # E: numpy.signedinteger[Any]
+reveal_type(u4 >> i4) # E: numpy.signedinteger[Any]
+reveal_type(u4 | i4) # E: numpy.signedinteger[Any]
+reveal_type(u4 ^ i4) # E: numpy.signedinteger[Any]
+reveal_type(u4 & i4) # E: numpy.signedinteger[Any]
+
+reveal_type(u4 << i) # E: numpy.signedinteger[Any]
+reveal_type(u4 >> i) # E: numpy.signedinteger[Any]
+reveal_type(u4 | i) # E: numpy.signedinteger[Any]
+reveal_type(u4 ^ i) # E: numpy.signedinteger[Any]
+reveal_type(u4 & i) # E: numpy.signedinteger[Any]
+
+reveal_type(u8 << b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 >> b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 | b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 ^ b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 & b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+
+reveal_type(u8 << b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 >> b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 | b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 ^ b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 & b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+
+reveal_type(b_ << b_) # E: numpy.signedinteger[numpy.typing._8Bit]
+reveal_type(b_ >> b_) # E: numpy.signedinteger[numpy.typing._8Bit]
reveal_type(b_ | b_) # E: numpy.bool_
reveal_type(b_ ^ b_) # E: numpy.bool_
reveal_type(b_ & b_) # E: numpy.bool_
-reveal_type(b_ << AR) # E: Union[numpy.ndarray, numpy.integer]
-reveal_type(b_ >> AR) # E: Union[numpy.ndarray, numpy.integer]
-reveal_type(b_ | AR) # E: Union[numpy.ndarray, numpy.integer, numpy.bool_]
-reveal_type(b_ ^ AR) # E: Union[numpy.ndarray, numpy.integer, numpy.bool_]
-reveal_type(b_ & AR) # E: Union[numpy.ndarray, numpy.integer, numpy.bool_]
+reveal_type(b_ << AR) # E: Union[numpy.ndarray, numpy.integer[Any]]
+reveal_type(b_ >> AR) # E: Union[numpy.ndarray, numpy.integer[Any]]
+reveal_type(b_ | AR) # E: Union[numpy.ndarray, numpy.integer[Any], numpy.bool_]
+reveal_type(b_ ^ AR) # E: Union[numpy.ndarray, numpy.integer[Any], numpy.bool_]
+reveal_type(b_ & AR) # E: Union[numpy.ndarray, numpy.integer[Any], numpy.bool_]
-reveal_type(b_ << b) # E: numpy.int8
-reveal_type(b_ >> b) # E: numpy.int8
+reveal_type(b_ << b) # E: numpy.signedinteger[numpy.typing._8Bit]
+reveal_type(b_ >> b) # E: numpy.signedinteger[numpy.typing._8Bit]
reveal_type(b_ | b) # E: numpy.bool_
reveal_type(b_ ^ b) # E: numpy.bool_
reveal_type(b_ & b) # E: numpy.bool_
-reveal_type(b_ << i) # E: Union[numpy.int32, numpy.int64]
-reveal_type(b_ >> i) # E: Union[numpy.int32, numpy.int64]
-reveal_type(b_ | i) # E: Union[numpy.int32, numpy.int64]
-reveal_type(b_ ^ i) # E: Union[numpy.int32, numpy.int64]
-reveal_type(b_ & i) # E: Union[numpy.int32, numpy.int64]
+reveal_type(b_ << i) # E: numpy.signedinteger[Any]
+reveal_type(b_ >> i) # E: numpy.signedinteger[Any]
+reveal_type(b_ | i) # E: numpy.signedinteger[Any]
+reveal_type(b_ ^ i) # E: numpy.signedinteger[Any]
+reveal_type(b_ & i) # E: numpy.signedinteger[Any]
-reveal_type(~i8) # E: numpy.int64
-reveal_type(~i4) # E: numpy.int32
-reveal_type(~u8) # E: numpy.uint64
-reveal_type(~u4) # E: numpy.uint32
+reveal_type(~i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(~i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(~u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(~u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
reveal_type(~b_) # E: numpy.bool_
-reveal_type(~AR) # E: Union[numpy.ndarray*, numpy.integer, numpy.bool_]
+reveal_type(~AR) # E: Union[numpy.ndarray*, numpy.integer[Any], numpy.bool_]
diff --git a/numpy/typing/tests/data/reveal/dtype.py b/numpy/typing/tests/data/reveal/dtype.py
index e0802299e..d414f2c49 100644
--- a/numpy/typing/tests/data/reveal/dtype.py
+++ b/numpy/typing/tests/data/reveal/dtype.py
@@ -1,30 +1,30 @@
import numpy as np
-reveal_type(np.dtype(np.float64)) # E: numpy.dtype[numpy.float64*]
-reveal_type(np.dtype(np.int64)) # E: numpy.dtype[numpy.int64*]
+reveal_type(np.dtype(np.float64)) # E: numpy.dtype[numpy.floating[numpy.typing._64Bit]]
+reveal_type(np.dtype(np.int64)) # E: numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]
# String aliases
-reveal_type(np.dtype("float64")) # E: numpy.dtype[numpy.float64]
-reveal_type(np.dtype("float32")) # E: numpy.dtype[numpy.float32]
-reveal_type(np.dtype("int64")) # E: numpy.dtype[numpy.int64]
-reveal_type(np.dtype("int32")) # E: numpy.dtype[numpy.int32]
+reveal_type(np.dtype("float64")) # E: numpy.dtype[numpy.floating[numpy.typing._64Bit]]
+reveal_type(np.dtype("float32")) # E: numpy.dtype[numpy.floating[numpy.typing._32Bit]]
+reveal_type(np.dtype("int64")) # E: numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]
+reveal_type(np.dtype("int32")) # E: numpy.dtype[numpy.signedinteger[numpy.typing._32Bit]]
reveal_type(np.dtype("bool")) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype("bytes")) # E: numpy.dtype[numpy.bytes_]
reveal_type(np.dtype("str")) # E: numpy.dtype[numpy.str_]
# Python types
-reveal_type(np.dtype(complex)) # E: numpy.dtype[numpy.complex128]
-reveal_type(np.dtype(float)) # E: numpy.dtype[numpy.float64]
+reveal_type(np.dtype(complex)) # E: numpy.dtype[numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]]
+reveal_type(np.dtype(float)) # E: numpy.dtype[numpy.floating[numpy.typing._64Bit]]
reveal_type(np.dtype(int)) # E: numpy.dtype
reveal_type(np.dtype(bool)) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype(str)) # E: numpy.dtype[numpy.str_]
reveal_type(np.dtype(bytes)) # E: numpy.dtype[numpy.bytes_]
# Special case for None
-reveal_type(np.dtype(None)) # E: numpy.dtype[numpy.float64]
+reveal_type(np.dtype(None)) # E: numpy.dtype[numpy.floating[numpy.typing._64Bit]]
# Dtypes of dtypes
-reveal_type(np.dtype(np.dtype(np.float64))) # E: numpy.dtype[numpy.float64*]
+reveal_type(np.dtype(np.dtype(np.float64))) # E: numpy.dtype[numpy.floating[numpy.typing._64Bit]]
# Parameterized dtypes
reveal_type(np.dtype("S8")) # E: numpy.dtype
diff --git a/numpy/typing/tests/data/reveal/fromnumeric.py b/numpy/typing/tests/data/reveal/fromnumeric.py
index 06501f6e2..75865c285 100644
--- a/numpy/typing/tests/data/reveal/fromnumeric.py
+++ b/numpy/typing/tests/data/reveal/fromnumeric.py
@@ -13,7 +13,7 @@ c = 1.0
d = np.array(1.0, dtype=np.float32) # writeable
reveal_type(np.take(a, 0)) # E: numpy.bool_
-reveal_type(np.take(b, 0)) # E: numpy.float32
+reveal_type(np.take(b, 0)) # E: numpy.floating[numpy.typing._32Bit]
reveal_type(
np.take(c, 0) # E: Union[numpy.generic, datetime.datetime, datetime.timedelta]
)
@@ -66,8 +66,8 @@ reveal_type(np.partition(c, 0, axis=None)) # E: numpy.ndarray
reveal_type(np.partition(A, 0)) # E: numpy.ndarray
reveal_type(np.partition(B, 0)) # E: numpy.ndarray
-reveal_type(np.argpartition(a, 0)) # E: numpy.integer
-reveal_type(np.argpartition(b, 0)) # E: numpy.integer
+reveal_type(np.argpartition(a, 0)) # E: numpy.integer[Any]
+reveal_type(np.argpartition(b, 0)) # E: numpy.integer[Any]
reveal_type(np.argpartition(c, 0)) # E: numpy.ndarray
reveal_type(np.argpartition(A, 0)) # E: numpy.ndarray
reveal_type(np.argpartition(B, 0)) # E: numpy.ndarray
@@ -78,18 +78,18 @@ reveal_type(np.sort(B, 0)) # E: numpy.ndarray
reveal_type(np.argsort(A, 0)) # E: numpy.ndarray
reveal_type(np.argsort(B, 0)) # E: numpy.ndarray
-reveal_type(np.argmax(A)) # E: numpy.integer
-reveal_type(np.argmax(B)) # E: numpy.integer
-reveal_type(np.argmax(A, axis=0)) # E: Union[numpy.integer, numpy.ndarray]
-reveal_type(np.argmax(B, axis=0)) # E: Union[numpy.integer, numpy.ndarray]
+reveal_type(np.argmax(A)) # E: numpy.integer[Any]
+reveal_type(np.argmax(B)) # E: numpy.integer[Any]
+reveal_type(np.argmax(A, axis=0)) # E: Union[numpy.integer[Any], numpy.ndarray]
+reveal_type(np.argmax(B, axis=0)) # E: Union[numpy.integer[Any], numpy.ndarray]
-reveal_type(np.argmin(A)) # E: numpy.integer
-reveal_type(np.argmin(B)) # E: numpy.integer
-reveal_type(np.argmin(A, axis=0)) # E: Union[numpy.integer, numpy.ndarray]
-reveal_type(np.argmin(B, axis=0)) # E: Union[numpy.integer, numpy.ndarray]
+reveal_type(np.argmin(A)) # E: numpy.integer[Any]
+reveal_type(np.argmin(B)) # E: numpy.integer[Any]
+reveal_type(np.argmin(A, axis=0)) # E: Union[numpy.integer[Any], numpy.ndarray]
+reveal_type(np.argmin(B, axis=0)) # E: Union[numpy.integer[Any], numpy.ndarray]
-reveal_type(np.searchsorted(A[0], 0)) # E: numpy.integer
-reveal_type(np.searchsorted(B[0], 0)) # E: numpy.integer
+reveal_type(np.searchsorted(A[0], 0)) # E: numpy.integer[Any]
+reveal_type(np.searchsorted(B[0], 0)) # E: numpy.integer[Any]
reveal_type(np.searchsorted(A[0], [0])) # E: numpy.ndarray
reveal_type(np.searchsorted(B[0], [0])) # E: numpy.ndarray
@@ -100,7 +100,7 @@ reveal_type(np.resize(A, (5, 5))) # E: numpy.ndarray
reveal_type(np.resize(B, (5, 5))) # E: numpy.ndarray
reveal_type(np.squeeze(a)) # E: numpy.bool_
-reveal_type(np.squeeze(b)) # E: numpy.float32
+reveal_type(np.squeeze(b)) # E: numpy.floating[numpy.typing._32Bit]
reveal_type(np.squeeze(c)) # E: numpy.ndarray
reveal_type(np.squeeze(A)) # E: numpy.ndarray
reveal_type(np.squeeze(B)) # E: numpy.ndarray
@@ -108,8 +108,8 @@ reveal_type(np.squeeze(B)) # E: numpy.ndarray
reveal_type(np.diagonal(A)) # E: numpy.ndarray
reveal_type(np.diagonal(B)) # E: numpy.ndarray
-reveal_type(np.trace(A)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.trace(B)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(np.trace(A)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.trace(B)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(np.ravel(a)) # E: numpy.ndarray
reveal_type(np.ravel(b)) # E: numpy.ndarray
@@ -135,19 +135,19 @@ reveal_type(np.compress([True], c)) # E: numpy.ndarray
reveal_type(np.compress([True], A)) # E: numpy.ndarray
reveal_type(np.compress([True], B)) # E: numpy.ndarray
-reveal_type(np.clip(a, 0, 1.0)) # E: numpy.number
-reveal_type(np.clip(b, -1, 1)) # E: numpy.float32
-reveal_type(np.clip(c, 0, 1)) # E: numpy.number
-reveal_type(np.clip(A, 0, 1)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.clip(B, 0, 1)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(np.clip(a, 0, 1.0)) # E: numpy.number[Any]
+reveal_type(np.clip(b, -1, 1)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.clip(c, 0, 1)) # E: numpy.number[Any]
+reveal_type(np.clip(A, 0, 1)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.clip(B, 0, 1)) # E: Union[numpy.number[Any], numpy.ndarray]
-reveal_type(np.sum(a)) # E: numpy.number
-reveal_type(np.sum(b)) # E: numpy.float32
-reveal_type(np.sum(c)) # E: numpy.number
-reveal_type(np.sum(A)) # E: numpy.number
-reveal_type(np.sum(B)) # E: numpy.number
-reveal_type(np.sum(A, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.sum(B, axis=0)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(np.sum(a)) # E: numpy.number[Any]
+reveal_type(np.sum(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.sum(c)) # E: numpy.number[Any]
+reveal_type(np.sum(A)) # E: numpy.number[Any]
+reveal_type(np.sum(B)) # E: numpy.number[Any]
+reveal_type(np.sum(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.sum(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(np.all(a)) # E: numpy.bool_
reveal_type(np.all(b)) # E: numpy.bool_
@@ -175,45 +175,45 @@ reveal_type(np.cumsum(c)) # E: numpy.ndarray
reveal_type(np.cumsum(A)) # E: numpy.ndarray
reveal_type(np.cumsum(B)) # E: numpy.ndarray
-reveal_type(np.ptp(a)) # E: numpy.number
-reveal_type(np.ptp(b)) # E: numpy.float32
-reveal_type(np.ptp(c)) # E: numpy.number
-reveal_type(np.ptp(A)) # E: numpy.number
-reveal_type(np.ptp(B)) # E: numpy.number
-reveal_type(np.ptp(A, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.ptp(B, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.ptp(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.ptp(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-
-reveal_type(np.amax(a)) # E: numpy.number
-reveal_type(np.amax(b)) # E: numpy.float32
-reveal_type(np.amax(c)) # E: numpy.number
-reveal_type(np.amax(A)) # E: numpy.number
-reveal_type(np.amax(B)) # E: numpy.number
-reveal_type(np.amax(A, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.amax(B, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.amax(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.amax(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-
-reveal_type(np.amin(a)) # E: numpy.number
-reveal_type(np.amin(b)) # E: numpy.float32
-reveal_type(np.amin(c)) # E: numpy.number
-reveal_type(np.amin(A)) # E: numpy.number
-reveal_type(np.amin(B)) # E: numpy.number
-reveal_type(np.amin(A, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.amin(B, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.amin(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.amin(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-
-reveal_type(np.prod(a)) # E: numpy.number
-reveal_type(np.prod(b)) # E: numpy.float32
-reveal_type(np.prod(c)) # E: numpy.number
-reveal_type(np.prod(A)) # E: numpy.number
-reveal_type(np.prod(B)) # E: numpy.number
-reveal_type(np.prod(A, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.prod(B, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.prod(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.prod(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(np.ptp(a)) # E: numpy.number[Any]
+reveal_type(np.ptp(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.ptp(c)) # E: numpy.number[Any]
+reveal_type(np.ptp(A)) # E: numpy.number[Any]
+reveal_type(np.ptp(B)) # E: numpy.number[Any]
+reveal_type(np.ptp(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.ptp(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.ptp(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.ptp(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+
+reveal_type(np.amax(a)) # E: numpy.number[Any]
+reveal_type(np.amax(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.amax(c)) # E: numpy.number[Any]
+reveal_type(np.amax(A)) # E: numpy.number[Any]
+reveal_type(np.amax(B)) # E: numpy.number[Any]
+reveal_type(np.amax(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.amax(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.amax(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.amax(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+
+reveal_type(np.amin(a)) # E: numpy.number[Any]
+reveal_type(np.amin(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.amin(c)) # E: numpy.number[Any]
+reveal_type(np.amin(A)) # E: numpy.number[Any]
+reveal_type(np.amin(B)) # E: numpy.number[Any]
+reveal_type(np.amin(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.amin(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.amin(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.amin(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+
+reveal_type(np.prod(a)) # E: numpy.number[Any]
+reveal_type(np.prod(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.prod(c)) # E: numpy.number[Any]
+reveal_type(np.prod(A)) # E: numpy.number[Any]
+reveal_type(np.prod(B)) # E: numpy.number[Any]
+reveal_type(np.prod(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.prod(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.prod(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.prod(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(np.prod(b, out=d)) # E: numpy.ndarray
reveal_type(np.prod(B, out=d)) # E: numpy.ndarray
@@ -235,44 +235,44 @@ reveal_type(np.size(c)) # E: int
reveal_type(np.size(A)) # E: int
reveal_type(np.size(B)) # E: int
-reveal_type(np.around(a)) # E: numpy.number
-reveal_type(np.around(b)) # E: numpy.float32
-reveal_type(np.around(c)) # E: numpy.number
+reveal_type(np.around(a)) # E: numpy.number[Any]
+reveal_type(np.around(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.around(c)) # E: numpy.number[Any]
reveal_type(np.around(A)) # E: numpy.ndarray
reveal_type(np.around(B)) # E: numpy.ndarray
-reveal_type(np.mean(a)) # E: numpy.number
-reveal_type(np.mean(b)) # E: numpy.number
-reveal_type(np.mean(c)) # E: numpy.number
-reveal_type(np.mean(A)) # E: numpy.number
-reveal_type(np.mean(B)) # E: numpy.number
-reveal_type(np.mean(A, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.mean(B, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.mean(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.mean(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(np.mean(a)) # E: numpy.number[Any]
+reveal_type(np.mean(b)) # E: numpy.number[Any]
+reveal_type(np.mean(c)) # E: numpy.number[Any]
+reveal_type(np.mean(A)) # E: numpy.number[Any]
+reveal_type(np.mean(B)) # E: numpy.number[Any]
+reveal_type(np.mean(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.mean(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.mean(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.mean(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(np.mean(b, out=d)) # E: numpy.ndarray
reveal_type(np.mean(B, out=d)) # E: numpy.ndarray
-reveal_type(np.std(a)) # E: numpy.number
-reveal_type(np.std(b)) # E: numpy.number
-reveal_type(np.std(c)) # E: numpy.number
-reveal_type(np.std(A)) # E: numpy.number
-reveal_type(np.std(B)) # E: numpy.number
-reveal_type(np.std(A, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.std(B, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.std(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.std(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(np.std(a)) # E: numpy.number[Any]
+reveal_type(np.std(b)) # E: numpy.number[Any]
+reveal_type(np.std(c)) # E: numpy.number[Any]
+reveal_type(np.std(A)) # E: numpy.number[Any]
+reveal_type(np.std(B)) # E: numpy.number[Any]
+reveal_type(np.std(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.std(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.std(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.std(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(np.std(b, out=d)) # E: numpy.ndarray
reveal_type(np.std(B, out=d)) # E: numpy.ndarray
-reveal_type(np.var(a)) # E: numpy.number
-reveal_type(np.var(b)) # E: numpy.number
-reveal_type(np.var(c)) # E: numpy.number
-reveal_type(np.var(A)) # E: numpy.number
-reveal_type(np.var(B)) # E: numpy.number
-reveal_type(np.var(A, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.var(B, axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.var(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(np.var(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(np.var(a)) # E: numpy.number[Any]
+reveal_type(np.var(b)) # E: numpy.number[Any]
+reveal_type(np.var(c)) # E: numpy.number[Any]
+reveal_type(np.var(A)) # E: numpy.number[Any]
+reveal_type(np.var(B)) # E: numpy.number[Any]
+reveal_type(np.var(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.var(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.var(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(np.var(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(np.var(b, out=d)) # E: numpy.ndarray
reveal_type(np.var(B, out=d)) # E: numpy.ndarray
diff --git a/numpy/typing/tests/data/reveal/nbit_base_example.py b/numpy/typing/tests/data/reveal/nbit_base_example.py
new file mode 100644
index 000000000..0c4c53f9b
--- /dev/null
+++ b/numpy/typing/tests/data/reveal/nbit_base_example.py
@@ -0,0 +1,18 @@
+from typing import TypeVar, Union
+import numpy as np
+import numpy.typing as npt
+
+T = TypeVar("T", bound=npt.NBitBase)
+
+def add(a: np.floating[T], b: np.integer[T]) -> np.floating[T]:
+ return a + b
+
+i8: np.int64
+i4: np.int32
+f8: np.float64
+f4: np.float32
+
+reveal_type(add(f8, i8)) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(add(f4, i8)) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(add(f8, i4)) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(add(f4, i4)) # E: numpy.floating[numpy.typing._32Bit]
diff --git a/numpy/typing/tests/data/reveal/ndarray_misc.py b/numpy/typing/tests/data/reveal/ndarray_misc.py
index 22a4564df..826c8aaa6 100644
--- a/numpy/typing/tests/data/reveal/ndarray_misc.py
+++ b/numpy/typing/tests/data/reveal/ndarray_misc.py
@@ -26,14 +26,14 @@ reveal_type(A.any(axis=0)) # E: Union[numpy.bool_, numpy.ndarray]
reveal_type(A.any(keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray]
reveal_type(A.any(out=B)) # E: SubClass
-reveal_type(f8.argmax()) # E: numpy.signedinteger
-reveal_type(A.argmax()) # E: numpy.signedinteger
-reveal_type(A.argmax(axis=0)) # E: Union[numpy.signedinteger, numpy.ndarray]
+reveal_type(f8.argmax()) # E: numpy.signedinteger[Any]
+reveal_type(A.argmax()) # E: numpy.signedinteger[Any]
+reveal_type(A.argmax(axis=0)) # E: Union[numpy.signedinteger[Any], numpy.ndarray]
reveal_type(A.argmax(out=B)) # E: SubClass
-reveal_type(f8.argmin()) # E: numpy.signedinteger
-reveal_type(A.argmin()) # E: numpy.signedinteger
-reveal_type(A.argmin(axis=0)) # E: Union[numpy.signedinteger, numpy.ndarray]
+reveal_type(f8.argmin()) # E: numpy.signedinteger[Any]
+reveal_type(A.argmin()) # E: numpy.signedinteger[Any]
+reveal_type(A.argmin(axis=0)) # E: Union[numpy.signedinteger[Any], numpy.ndarray]
reveal_type(A.argmin(out=B)) # E: SubClass
reveal_type(f8.argsort()) # E: numpy.ndarray
@@ -43,9 +43,9 @@ reveal_type(f8.astype(np.int64).choose([()])) # E: numpy.ndarray
reveal_type(A.choose([0])) # E: numpy.ndarray
reveal_type(A.choose([0], out=B)) # E: SubClass
-reveal_type(f8.clip(1)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.clip(1)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.clip(None, 1)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(f8.clip(1)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.clip(1)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.clip(None, 1)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.clip(1, out=B)) # E: SubClass
reveal_type(A.clip(None, 1, out=B)) # E: SubClass
@@ -53,11 +53,11 @@ reveal_type(f8.compress([0])) # E: numpy.ndarray
reveal_type(A.compress([0])) # E: numpy.ndarray
reveal_type(A.compress([0], out=B)) # E: SubClass
-reveal_type(f8.conj()) # E: numpy.float64
+reveal_type(f8.conj()) # E: numpy.floating[numpy.typing._64Bit]
reveal_type(A.conj()) # E: numpy.ndarray
reveal_type(B.conj()) # E: SubClass
-reveal_type(f8.conjugate()) # E: numpy.float64
+reveal_type(f8.conjugate()) # E: numpy.floating[numpy.typing._64Bit]
reveal_type(A.conjugate()) # E: numpy.ndarray
reveal_type(B.conjugate()) # E: SubClass
@@ -69,41 +69,41 @@ reveal_type(f8.cumsum()) # E: numpy.ndarray
reveal_type(A.cumsum()) # E: numpy.ndarray
reveal_type(A.cumsum(out=B)) # E: SubClass
-reveal_type(f8.max()) # E: numpy.number
-reveal_type(A.max()) # E: numpy.number
-reveal_type(A.max(axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.max(keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(f8.max()) # E: numpy.number[Any]
+reveal_type(A.max()) # E: numpy.number[Any]
+reveal_type(A.max(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.max(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.max(out=B)) # E: SubClass
-reveal_type(f8.mean()) # E: numpy.number
-reveal_type(A.mean()) # E: numpy.number
-reveal_type(A.mean(axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.mean(keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(f8.mean()) # E: numpy.number[Any]
+reveal_type(A.mean()) # E: numpy.number[Any]
+reveal_type(A.mean(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.mean(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.mean(out=B)) # E: SubClass
-reveal_type(f8.min()) # E: numpy.number
-reveal_type(A.min()) # E: numpy.number
-reveal_type(A.min(axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.min(keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(f8.min()) # E: numpy.number[Any]
+reveal_type(A.min()) # E: numpy.number[Any]
+reveal_type(A.min(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.min(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.min(out=B)) # E: SubClass
-reveal_type(f8.newbyteorder()) # E: numpy.float64
+reveal_type(f8.newbyteorder()) # E: numpy.floating[numpy.typing._64Bit]
reveal_type(A.newbyteorder()) # E: numpy.ndarray
reveal_type(B.newbyteorder('|')) # E: SubClass
-reveal_type(f8.prod()) # E: numpy.number
-reveal_type(A.prod()) # E: numpy.number
-reveal_type(A.prod(axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.prod(keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(f8.prod()) # E: numpy.number[Any]
+reveal_type(A.prod()) # E: numpy.number[Any]
+reveal_type(A.prod(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.prod(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.prod(out=B)) # E: SubClass
-reveal_type(f8.ptp()) # E: numpy.number
-reveal_type(A.ptp()) # E: numpy.number
-reveal_type(A.ptp(axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.ptp(keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(f8.ptp()) # E: numpy.number[Any]
+reveal_type(A.ptp()) # E: numpy.number[Any]
+reveal_type(A.ptp(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.ptp(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.ptp(out=B)) # E: SubClass
-reveal_type(f8.round()) # E: numpy.float64
+reveal_type(f8.round()) # E: numpy.floating[numpy.typing._64Bit]
reveal_type(A.round()) # E: numpy.ndarray
reveal_type(A.round(out=B)) # E: SubClass
@@ -111,16 +111,16 @@ reveal_type(f8.repeat(1)) # E: numpy.ndarray
reveal_type(A.repeat(1)) # E: numpy.ndarray
reveal_type(B.repeat(1)) # E: numpy.ndarray
-reveal_type(f8.std()) # E: numpy.number
-reveal_type(A.std()) # E: numpy.number
-reveal_type(A.std(axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.std(keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(f8.std()) # E: numpy.number[Any]
+reveal_type(A.std()) # E: numpy.number[Any]
+reveal_type(A.std(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.std(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.std(out=B)) # E: SubClass
-reveal_type(f8.sum()) # E: numpy.number
-reveal_type(A.sum()) # E: numpy.number
-reveal_type(A.sum(axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.sum(keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(f8.sum()) # E: numpy.number[Any]
+reveal_type(A.sum()) # E: numpy.number[Any]
+reveal_type(A.sum(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.sum(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.sum(out=B)) # E: SubClass
reveal_type(f8.take(0)) # E: numpy.generic
@@ -129,22 +129,22 @@ reveal_type(A.take([0])) # E: numpy.ndarray
reveal_type(A.take(0, out=B)) # E: SubClass
reveal_type(A.take([0], out=B)) # E: SubClass
-reveal_type(f8.var()) # E: numpy.number
-reveal_type(A.var()) # E: numpy.number
-reveal_type(A.var(axis=0)) # E: Union[numpy.number, numpy.ndarray]
-reveal_type(A.var(keepdims=True)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(f8.var()) # E: numpy.number[Any]
+reveal_type(A.var()) # E: numpy.number[Any]
+reveal_type(A.var(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray]
+reveal_type(A.var(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.var(out=B)) # E: SubClass
reveal_type(A.argpartition([0])) # E: numpy.ndarray
reveal_type(A.diagonal()) # E: numpy.ndarray
-reveal_type(A.dot(1)) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(A.dot(1)) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.dot(1, out=B)) # E: SubClass
reveal_type(A.nonzero()) # E: tuple[numpy.ndarray]
reveal_type(A.searchsorted([1])) # E: numpy.ndarray
-reveal_type(A.trace()) # E: Union[numpy.number, numpy.ndarray]
+reveal_type(A.trace()) # E: Union[numpy.number[Any], numpy.ndarray]
reveal_type(A.trace(out=B)) # E: SubClass
diff --git a/numpy/typing/tests/data/reveal/scalars.py b/numpy/typing/tests/data/reveal/scalars.py
index 0168ebed8..72a3e4d2e 100644
--- a/numpy/typing/tests/data/reveal/scalars.py
+++ b/numpy/typing/tests/data/reveal/scalars.py
@@ -2,18 +2,18 @@ import numpy as np
x = np.complex64(3 + 2j)
-reveal_type(x.real) # E: numpy.float32
-reveal_type(x.imag) # E: numpy.float32
+reveal_type(x.real) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(x.imag) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(x.real.real) # E: numpy.float32
-reveal_type(x.real.imag) # E: numpy.float32
+reveal_type(x.real.real) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(x.real.imag) # E: numpy.floating[numpy.typing._32Bit]
reveal_type(x.itemsize) # E: int
reveal_type(x.shape) # E: tuple[builtins.int]
reveal_type(x.strides) # E: tuple[builtins.int]
-reveal_type(np.complex64().real) # E: numpy.float32
-reveal_type(np.complex128().imag) # E: numpy.float64
+reveal_type(np.complex64().real) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.complex128().imag) # E: numpy.floating[numpy.typing._64Bit]
reveal_type(np.unicode_('foo')) # E: numpy.str_
reveal_type(np.str0('foo')) # E: numpy.str_
diff --git a/numpy/typing/tests/test_typing.py b/numpy/typing/tests/test_typing.py
index cba1dc1be..709eda7a6 100644
--- a/numpy/typing/tests/test_typing.py
+++ b/numpy/typing/tests/test_typing.py
@@ -114,9 +114,10 @@ def test_reveal(path):
])
with open(path) as fin:
- lines = fin.readlines()
+ lines = fin.read().replace('*', '').split("\n")
- for error_line in stdout.split("\n"):
+ stdout_list = stdout.replace('*', '').split("\n")
+ for error_line in stdout_list:
error_line = error_line.strip()
if not error_line:
continue