Skip to content

Commit 8c46459

Browse files
authored
Merge pull request numpy#27736 from jorenham/typing/scalar-type-parameter-defaults
TYP: Optional ``numpy.number`` type parameters
2 parents 14ef9d0 + 68ddb40 commit 8c46459

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* The "nbit" type parameter of ``np.number`` and its subtypes now defaults
2+
to ``typing.Any``. This way, type-checkers will infer annotations such as
3+
``x: np.floating`` as ``x: np.floating[Any]``, even in strict mode.

numpy/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3081,8 +3081,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
30813081
# See https://github.com/numpy/numpy-stubs/pull/80 for more details.
30823082

30833083
_ScalarType = TypeVar("_ScalarType", bound=generic)
3084-
_NBit = TypeVar("_NBit", bound=NBitBase)
3085-
_NBit1 = TypeVar("_NBit1", bound=NBitBase)
3084+
_NBit = TypeVar("_NBit", bound=NBitBase, default=Any)
3085+
_NBit1 = TypeVar("_NBit1", bound=NBitBase, default=Any)
30863086
_NBit2 = TypeVar("_NBit2", bound=NBitBase, default=_NBit1)
30873087
_NBit_fc = TypeVar("_NBit_fc", _NBitHalf, _NBitSingle, _NBitDouble, _NBitLongDouble)
30883088

0 commit comments

Comments
 (0)