diff --git a/src/numpy-stubs/__init__.pyi b/src/numpy-stubs/__init__.pyi index e1906c97..483fff1c 100644 --- a/src/numpy-stubs/__init__.pyi +++ b/src/numpy-stubs/__init__.pyi @@ -4272,6 +4272,9 @@ float32: TypeAlias = floating[_32Bit] # either a C `double`, `float`, or `longdouble` class float64(floating[_64Bit], float): # type: ignore[misc] + def __new__(cls, x: _ConvertibleToFloat | None = ..., /) -> Self: ... + + # @property def itemsize(self) -> L[8]: ... @property @@ -4434,7 +4437,15 @@ class complexfloating(inexact[_NBit1, complex], Generic[_NBit1, _NBit2]): def imag(self) -> floating[_NBit2]: ... # - def __init__(self, value: _ConvertibleToComplex | None = ..., /) -> None: ... + @overload + def __init__( + self, + real: complex | SupportsComplex | SupportsFloat | SupportsIndex = ..., + imag: complex | SupportsFloat | SupportsIndex = ..., + /, + ) -> None: ... + @overload + def __init__(self, real: _ConvertibleToComplex | None = ..., /) -> None: ... # NOTE: `__complex__` is technically defined in the concrete subtypes def __complex__(self, /) -> complex: ... @@ -4530,6 +4541,17 @@ class complexfloating(inexact[_NBit1, complex], Generic[_NBit1, _NBit2]): def __rpow__(self, other: number[_NBit], /) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit]: ... class complex128(complexfloating[_64Bit], complex): # type: ignore[misc] + @overload + def __new__( + cls, + real: complex | SupportsComplex | SupportsFloat | SupportsIndex = ..., + imag: complex | SupportsFloat | SupportsIndex = ..., + /, + ) -> Self: ... + @overload + def __new__(cls, real: _ConvertibleToComplex | None = ..., /) -> Self: ... + + # @property def itemsize(self) -> L[16]: ... @property @@ -4917,9 +4939,15 @@ class character(flexible[_CharacterItemT_co], Generic[_CharacterItemT_co]): class bytes_(character[bytes], bytes): @overload - def __init__(self, value: object = ..., /) -> None: ... + def __new__(cls, o: object = ..., /) -> Self: ... + @overload + def __new__(cls, s: str, /, encoding: str, errors: str = ...) -> Self: ... + + # + @overload + def __init__(self, o: object = ..., /) -> None: ... @overload - def __init__(self, value: str, /, encoding: str = ..., errors: str = ...) -> None: ... + def __init__(self, s: str, /, encoding: str, errors: str = ...) -> None: ... # def __bytes__(self, /) -> bytes: ... diff --git a/test/static/reject/scalars.pyi b/test/static/reject/scalars.pyi index 74a9d73c..7c6bf1fa 100644 --- a/test/static/reject/scalars.pyi +++ b/test/static/reject/scalars.pyi @@ -14,8 +14,7 @@ class A: np.float32(3j) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] np.float32([1.0, 0.0, 0.0]) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] -np.complex64([]) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] -np.complex64(1, 2) # type: ignore[call-arg] # pyright: ignore[reportCallIssue] +np.complex64([]) # type: ignore[call-overload] # pyright: ignore[reportCallIssue,reportArgumentType] np.datetime64(0) # type: ignore[call-overload] # pyright: ignore[reportCallIssue,reportArgumentType] @@ -42,7 +41,7 @@ np.flexible(b"test") # type: ignore[abstract] np.float64(value=0.0) # type: ignore[call-arg] # pyright: ignore[reportCallIssue] np.int64(value=0) # type: ignore[call-arg] # pyright: ignore[reportCallIssue] np.uint64(value=0) # type: ignore[call-arg] # pyright: ignore[reportCallIssue] -np.complex128(value=0.0j) # type: ignore[call-arg] # pyright: ignore[reportCallIssue] +np.complex128(value=0.0j) # type: ignore[call-overload] # pyright: ignore[reportCallIssue] np.str_(value="bob") # type: ignore[call-overload] # pyright: ignore[reportCallIssue] np.bytes_(value=b"test") # type: ignore[call-overload] # pyright: ignore[reportCallIssue] np.void(value=b"test") # type: ignore[call-overload] # pyright: ignore[reportCallIssue]