diff --git a/src/numpy-stubs/__init__.pyi b/src/numpy-stubs/__init__.pyi index 7ef1e2ac..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 @@ -1109,111 +1110,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: ... # @@ -4944,15 +4950,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 @@ -5018,9 +5024,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 @@ -5411,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 98660e00..bfa3eb42 100644 --- a/tool/allowlists/todo.txt +++ b/tool/allowlists/todo.txt @@ -29,25 +29,14 @@ 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__ -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__ numpy._core.umath.__all__ -numpy._core.void.__new__ numpy.array2string numpy.char.chararray.argsort numpy.core._internal._ctypes.get_as_parameter @@ -58,19 +47,11 @@ 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__ -numpy.core.numeric.void.__new__ -numpy.core.numerictypes.object_.__new__ -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,25 +180,18 @@ 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 numpy.matlib.ndindex.ndincr -numpy.matlib.object_.__new__ numpy.matlib.percentile numpy.matlib.reshape numpy.matlib.save numpy.matlib.trapz -numpy.matlib.ufunc.__signature__ -numpy.matlib.void.__new__ numpy.nanpercentile numpy.ndindex.ndincr -numpy.object_.__new__ numpy.percentile numpy.reshape numpy.save numpy.strings.slice numpy.trapz -numpy.ufunc.__signature__ -numpy.void.__new__