From 3b0f4c9262edefa7f9c162cc1b7230f7eded5bce Mon Sep 17 00:00:00 2001 From: jorenham Date: Tue, 23 Dec 2025 14:38:26 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20`np.dtype.=5F=5Fnew?= =?UTF-8?q?=5F=5F`:=20keyword-only=20`metadata`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/numpy-stubs/__init__.pyi | 59 +++++++++++++++++++----------------- tool/allowlists/todo.txt | 7 ----- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/numpy-stubs/__init__.pyi b/src/numpy-stubs/__init__.pyi index 7ef1e2ac..43a02930 100644 --- a/src/numpy-stubs/__init__.pyi +++ b/src/numpy-stubs/__init__.pyi @@ -1109,111 +1109,116 @@ class dtype(Generic[_ScalarT_co], metaclass=_DTypeMeta): # @overload def __new__( - cls, dtype: _nt.ToDTypeBool, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeBool, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.BoolDType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeInt8, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeInt8, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.Int8DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeUInt8, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeUInt8, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.UInt8DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeInt16, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeInt16, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.Int16DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeUInt16, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeUInt16, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.UInt16DType: ... @overload def __new__( # type: ignore[overload-overlap] - cls, dtype: _nt.ToDTypeLong, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeLong, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.LongDType: ... @overload def __new__( # type: ignore[overload-overlap] - cls, dtype: _nt.ToDTypeULong, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeULong, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.ULongDType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeInt32, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeInt32, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.Int32DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeUInt32, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeUInt32, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.UInt32DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeInt64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeInt64, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.Int64DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeUInt64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeUInt64, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.UInt64DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeFloat16, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeFloat16, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.Float16DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeFloat32, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeFloat32, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.Float32DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeFloat64 | None, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, + dtype: _nt.ToDTypeFloat64 | None, + align: py_bool = False, + copy: py_bool = False, + *, + metadata: _MetaData = ..., ) -> dtypes.Float64DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeLongDouble, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeLongDouble, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.LongDoubleDType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeComplex64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeComplex64, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.Complex64DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeComplex128, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeComplex128, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.Complex128DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeCLongDouble, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeCLongDouble, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.CLongDoubleDType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeObject, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeObject, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.ObjectDType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeBytes, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeBytes, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.BytesDType: ... @overload def __new__( # type: ignore[overload-overlap] - cls, dtype: _nt.ToDTypeStr, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeStr, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.StrDType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeVoid, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeVoid, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.VoidDType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeDateTime64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeDateTime64, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.DateTime64DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeTimeDelta64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeTimeDelta64, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.TimeDelta64DType: ... @overload def __new__( - cls, dtype: _nt.ToDTypeString, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _nt.ToDTypeString, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtypes.StringDType: ... @overload def __new__( - cls, dtype: _DTypeLike[_ScalarT_co], align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: _DTypeLike[_ScalarT_co], align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> Self: ... @overload def __new__( - cls, dtype: DTypeLike, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ... + cls, dtype: DTypeLike, align: py_bool = False, copy: py_bool = False, *, metadata: _MetaData = ... ) -> dtype: ... # diff --git a/tool/allowlists/todo.txt b/tool/allowlists/todo.txt index 98660e00..9b31e578 100644 --- a/tool/allowlists/todo.txt +++ b/tool/allowlists/todo.txt @@ -29,13 +29,10 @@ numpy._core._type_aliases.v numpy._core.array2string numpy._core.arrayprint.array2string numpy._core.defchararray.chararray.argsort -numpy._core.dtype.__new__ numpy._core.finfo.smallest_normal numpy._core.fromnumeric.reshape numpy._core.getlimits.finfo.smallest_normal -numpy._core.multiarray.dtype.__new__ numpy._core.numeric.array2string -numpy._core.numeric.dtype.__new__ numpy._core.numeric.object_.__new__ numpy._core.numeric.reshape numpy._core.numeric.ufunc.__signature__ @@ -58,9 +55,7 @@ numpy.core.arrayprint.array2string numpy.core.defchararray.chararray.argsort numpy.core.fromnumeric.reshape numpy.core.getlimits.finfo.smallest_normal -numpy.core.multiarray.dtype.__new__ numpy.core.numeric.array2string -numpy.core.numeric.dtype.__new__ numpy.core.numeric.object_.__new__ numpy.core.numeric.reshape numpy.core.numeric.ufunc.__signature__ @@ -70,7 +65,6 @@ numpy.core.numerictypes.void.__new__ numpy.core.umath.__all__ numpy.core.umath.matmul numpy.corrcoef -numpy.dtype.__new__ numpy.f2py._backends._meson.MesonTemplate.objects_substitution numpy.fft.helper numpy.finfo.smallest_normal @@ -199,7 +193,6 @@ numpy.ma.zeros numpy.ma.zeros_like numpy.matlib.array2string numpy.matlib.corrcoef -numpy.matlib.dtype.__new__ numpy.matlib.finfo.smallest_normal numpy.matlib.in1d numpy.matlib.nanpercentile From 66765c8140d6ee33457efd0bea9df5a751daf9ee Mon Sep 17 00:00:00 2001 From: jorenham Date: Tue, 23 Dec 2025 14:43:05 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=B4=20`np.object=5F.=5F=5Fnew=5F?= =?UTF-8?q?=5F`:=20rename=20posonly=20param=20to=20work=20around=20a=20stu?= =?UTF-8?q?btest=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/numpy-stubs/__init__.pyi | 10 +++++----- tool/allowlists/todo.txt | 7 ------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/numpy-stubs/__init__.pyi b/src/numpy-stubs/__init__.pyi index 43a02930..64fde82a 100644 --- a/src/numpy-stubs/__init__.pyi +++ b/src/numpy-stubs/__init__.pyi @@ -4949,15 +4949,15 @@ complex256 = clongdouble @final class object_(_RealMixin, generic[Any]): @overload - def __new__(cls, nothing_to_see_here: None = None, /) -> None: ... # type: ignore[misc] + def __new__(cls, value: None = None, /) -> None: ... # type: ignore[misc] @overload - def __new__(cls, stringy: str, /) -> str: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload] + def __new__(cls, value: str, /) -> str: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload] @overload - def __new__(cls, stringy: bytes, /) -> bytes: ... # type: ignore[misc] + def __new__(cls, value: bytes, /) -> bytes: ... # type: ignore[misc] @overload - def __new__(cls, array: ndarray[_ShapeT], /) -> _nt.Array[Self, _ShapeT]: ... # type: ignore[misc] + def __new__(cls, value: ndarray[_ShapeT], /) -> _nt.Array[Self, _ShapeT]: ... # type: ignore[misc] @overload - def __new__(cls, sequence: SupportsLenAndGetItem[object], /) -> _nt.Array[Self]: ... # type: ignore[misc] + def __new__(cls, value: SupportsLenAndGetItem[object], /) -> _nt.Array[Self]: ... # type: ignore[misc] @overload def __new__(cls, value: _T, /) -> _T: ... # type: ignore[misc] @overload # catch-all diff --git a/tool/allowlists/todo.txt b/tool/allowlists/todo.txt index 9b31e578..6c0081a4 100644 --- a/tool/allowlists/todo.txt +++ b/tool/allowlists/todo.txt @@ -33,13 +33,10 @@ numpy._core.finfo.smallest_normal numpy._core.fromnumeric.reshape numpy._core.getlimits.finfo.smallest_normal numpy._core.numeric.array2string -numpy._core.numeric.object_.__new__ numpy._core.numeric.reshape numpy._core.numeric.ufunc.__signature__ numpy._core.numeric.void.__new__ -numpy._core.numerictypes.object_.__new__ numpy._core.numerictypes.void.__new__ -numpy._core.object_.__new__ numpy._core.reshape numpy._core.strings.slice numpy._core.ufunc.__signature__ @@ -56,11 +53,9 @@ numpy.core.defchararray.chararray.argsort numpy.core.fromnumeric.reshape numpy.core.getlimits.finfo.smallest_normal numpy.core.numeric.array2string -numpy.core.numeric.object_.__new__ numpy.core.numeric.reshape numpy.core.numeric.ufunc.__signature__ numpy.core.numeric.void.__new__ -numpy.core.numerictypes.object_.__new__ numpy.core.numerictypes.void.__new__ numpy.core.umath.__all__ numpy.core.umath.matmul @@ -197,7 +192,6 @@ numpy.matlib.finfo.smallest_normal numpy.matlib.in1d numpy.matlib.nanpercentile numpy.matlib.ndindex.ndincr -numpy.matlib.object_.__new__ numpy.matlib.percentile numpy.matlib.reshape numpy.matlib.save @@ -206,7 +200,6 @@ numpy.matlib.ufunc.__signature__ numpy.matlib.void.__new__ numpy.nanpercentile numpy.ndindex.ndincr -numpy.object_.__new__ numpy.percentile numpy.reshape numpy.save From 9b515b99500c6b3193c864fa0b08e79313eb10af Mon Sep 17 00:00:00 2001 From: jorenham Date: Tue, 23 Dec 2025 14:47:13 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=B4=20`np.void.=5F=5Fnew=5F=5F`:?= =?UTF-8?q?=20rename=20posonly=20param=20to=20work=20around=20a=20stubtest?= =?UTF-8?q?=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/numpy-stubs/__init__.pyi | 4 ++-- tool/allowlists/todo.txt | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/numpy-stubs/__init__.pyi b/src/numpy-stubs/__init__.pyi index 64fde82a..732de1c1 100644 --- a/src/numpy-stubs/__init__.pyi +++ b/src/numpy-stubs/__init__.pyi @@ -5023,9 +5023,9 @@ class str_(character[str], str): # type: ignore[misc] class void(flexible[bytes | tuple[Any, ...]]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] @overload - def __new__(cls, value: _nt.CoInteger_0d | bytes, /, dtype: None = None) -> Self: ... + def __new__(cls, length_or_data: _nt.CoInteger_0d | bytes, /, dtype: None = None) -> Self: ... @overload - def __new__(cls, value: Any, /, dtype: _DTypeLikeVoid) -> Self: ... + def __new__(cls, length_or_data: object, /, dtype: _DTypeLikeVoid) -> Self: ... # @type_check_only diff --git a/tool/allowlists/todo.txt b/tool/allowlists/todo.txt index 6c0081a4..0d7b47a3 100644 --- a/tool/allowlists/todo.txt +++ b/tool/allowlists/todo.txt @@ -35,13 +35,10 @@ numpy._core.getlimits.finfo.smallest_normal numpy._core.numeric.array2string numpy._core.numeric.reshape numpy._core.numeric.ufunc.__signature__ -numpy._core.numeric.void.__new__ -numpy._core.numerictypes.void.__new__ numpy._core.reshape numpy._core.strings.slice numpy._core.ufunc.__signature__ numpy._core.umath.__all__ -numpy._core.void.__new__ numpy.array2string numpy.char.chararray.argsort numpy.core._internal._ctypes.get_as_parameter @@ -55,8 +52,6 @@ numpy.core.getlimits.finfo.smallest_normal numpy.core.numeric.array2string numpy.core.numeric.reshape numpy.core.numeric.ufunc.__signature__ -numpy.core.numeric.void.__new__ -numpy.core.numerictypes.void.__new__ numpy.core.umath.__all__ numpy.core.umath.matmul numpy.corrcoef @@ -197,7 +192,6 @@ numpy.matlib.reshape numpy.matlib.save numpy.matlib.trapz numpy.matlib.ufunc.__signature__ -numpy.matlib.void.__new__ numpy.nanpercentile numpy.ndindex.ndincr numpy.percentile @@ -206,4 +200,3 @@ numpy.save numpy.strings.slice numpy.trapz numpy.ufunc.__signature__ -numpy.void.__new__ From f3d1fe0d7e490eab26b4787058e9c806f38f80d6 Mon Sep 17 00:00:00 2001 From: jorenham Date: Tue, 23 Dec 2025 14:56:55 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20`ufunc.=5F=5Fsignat?= =?UTF-8?q?ure=5F=5F`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/numpy-stubs/__init__.pyi | 3 +++ tool/allowlists/todo.txt | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/numpy-stubs/__init__.pyi b/src/numpy-stubs/__init__.pyi index 732de1c1..53fa2db1 100644 --- a/src/numpy-stubs/__init__.pyi +++ b/src/numpy-stubs/__init__.pyi @@ -1,5 +1,6 @@ import ctypes as ct import datetime as dt +import inspect import sys from _typeshed import Incomplete, StrOrBytesPath, SupportsFlush, SupportsLenAndGetItem, SupportsWrite from builtins import bool as py_bool @@ -5416,6 +5417,8 @@ _OuterT_co = TypeVar( @final class ufunc(Generic[_CallT_co, _AtT_co, _ReduceT_co, _ReduceAtT_co, _AccumulateT_co, _OuterT_co]): + __signature__: Final[inspect.Signature] + __call__: _CallT_co # method at: _AtT_co # method reduce: _ReduceT_co # method diff --git a/tool/allowlists/todo.txt b/tool/allowlists/todo.txt index 0d7b47a3..bfa3eb42 100644 --- a/tool/allowlists/todo.txt +++ b/tool/allowlists/todo.txt @@ -34,10 +34,8 @@ numpy._core.fromnumeric.reshape numpy._core.getlimits.finfo.smallest_normal numpy._core.numeric.array2string numpy._core.numeric.reshape -numpy._core.numeric.ufunc.__signature__ numpy._core.reshape numpy._core.strings.slice -numpy._core.ufunc.__signature__ numpy._core.umath.__all__ numpy.array2string numpy.char.chararray.argsort @@ -51,7 +49,6 @@ numpy.core.fromnumeric.reshape numpy.core.getlimits.finfo.smallest_normal numpy.core.numeric.array2string numpy.core.numeric.reshape -numpy.core.numeric.ufunc.__signature__ numpy.core.umath.__all__ numpy.core.umath.matmul numpy.corrcoef @@ -191,7 +188,6 @@ numpy.matlib.percentile numpy.matlib.reshape numpy.matlib.save numpy.matlib.trapz -numpy.matlib.ufunc.__signature__ numpy.nanpercentile numpy.ndindex.ndincr numpy.percentile @@ -199,4 +195,3 @@ numpy.reshape numpy.save numpy.strings.slice numpy.trapz -numpy.ufunc.__signature__