Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/numpy-stubs/@test/static/reject/comparisons.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ AR_c > b"" # type: ignore[operator] # pyright: ignore[reportOperatorIssue]

AR_m > AR_f # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
AR_m > AR_c # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
AR_m > AR_M # type: ignore[operator]
AR_m > AR_M
AR_m > "" # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
AR_m > b"" # type: ignore[operator] # pyright: ignore[reportOperatorIssue]

Expand All @@ -34,6 +34,6 @@ AR_m > b"" # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
AR_M > AR_i # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
AR_M > AR_f # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
AR_M > AR_c # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
AR_M > AR_m # type: ignore[operator]
AR_M > AR_m
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an error, so something broke.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll look into this then ..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you can't figure it out: dtype promotion in numtype is very complicated stuff (I barely understand it myself tbh).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i restore it , and got these errors on running

src/numpy-stubs/@test/static/reject/comparisons.pyi:28: error: Unused "type: ignore" comment  [unused-ignore]
src/numpy-stubs/@test/static/reject/comparisons.pyi:37: error: Unused "type: ignore" comment  [unused-ignore]

are we expecting these...

Let me know if you can't figure it out: dtype promotion in numtype is very complicated stuff (I barely understand it myself tbh).

or maybe i'll need help with this .

AR_M > "" # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
AR_M > b"" # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
2 changes: 1 addition & 1 deletion src/numpy-stubs/@test/static/reject/rec.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ np.rec.fromarrays( # type: ignore[call-overload] # pyright: ignore[reportCallI
formats=["f8", "f8"], # pyright: ignore[reportArgumentType]
)

np.rec.fromrecords(AR_i8) # type: ignore[arg-type]
np.rec.fromrecords(AR_i8)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should also report an error

np.rec.fromrecords( # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
[(1.5,)],
dtype=[("f8", "f8")],
Expand Down
14 changes: 7 additions & 7 deletions src/numpy-stubs/_core/_multiarray_umath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def empty(
like: _CanArrayFunc | None = None,
) -> _nt.Array[np.float64, _AnyShapeT]: ...
@overload # known shape, known dtype (mypy reports a false positive)
def empty( # type: ignore[overload-overlap]
def empty(
shape: _AnyShapeT,
dtype: _DTypeT | _HasDType[_DTypeT],
order: _OrderCF = "C",
Expand Down Expand Up @@ -640,7 +640,7 @@ def zeros(
like: _CanArrayFunc | None = None,
) -> _nt.Array[np.float64, _AnyShapeT]: ...
@overload # known shape, known dtype (mypy reports a false positive)
def zeros( # type: ignore[overload-overlap]
def zeros(
shape: _AnyShapeT,
dtype: _DTypeT | _HasDType[_DTypeT],
order: _OrderCF = "C",
Expand Down Expand Up @@ -782,7 +782,7 @@ def empty_like(
device: _Device | None = None,
) -> _nt.Array3D[np.bool_]: ...
@overload # workaround for microsoft/pyright#10232
def empty_like( # type: ignore[overload-overlap] # python/mypy#19908
def empty_like( # python/mypy#19908
prototype: _nt._ToArray_nnd[np.intp],
/,
dtype: _nt.ToDTypeInt64 | None = None,
Expand Down Expand Up @@ -837,7 +837,7 @@ def empty_like(
device: _Device | None = None,
) -> _nt.Array3D[np.intp]: ...
@overload # workaround for microsoft/pyright#10232
def empty_like( # type: ignore[overload-overlap] # python/mypy#19908
def empty_like( # python/mypy#19908
prototype: _nt._ToArray_nnd[np.float64],
/,
dtype: _nt.ToDTypeFloat64 | None = None,
Expand Down Expand Up @@ -947,7 +947,7 @@ def empty_like(
device: _Device | None = None,
) -> _nt.Array3D[np.complex128]: ...
@overload # array-like with known scalar-type, given shape
def empty_like( # type: ignore[overload-overlap]
def empty_like(
prototype: _ArrayLike[_ScalarT],
/,
dtype: np.dtype[_ScalarT] | None = None,
Expand All @@ -969,7 +969,7 @@ def empty_like(
device: _Device | None = None,
) -> _nt.Array[_ScalarT]: ...
@overload # given shape, given dtype
def empty_like( # type: ignore[overload-overlap]
def empty_like(
prototype: object,
/,
dtype: _DTypeT | _HasDType[_DTypeT],
Expand Down Expand Up @@ -1671,7 +1671,7 @@ def dot(a: npt.ArrayLike, b: npt.ArrayLike, out: _ArrayT) -> _ArrayT: ...

#
@overload
def vdot(a: _ArrayLike[_NumericT], b: _ArrayLike[_NumericT], /) -> _NumericT: ... # type: ignore[overload-overlap]
def vdot(a: _ArrayLike[_NumericT], b: _ArrayLike[_NumericT], /) -> _NumericT: ...
@overload
def vdot(a: _nt.CoInteger_nd, b: _nt.CoInteger_nd, /) -> np.signedinteger: ...
@overload
Expand Down
105 changes: 66 additions & 39 deletions src/numpy-stubs/_core/strings.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ from .umath import (
str_len,
)

ToAnyStringND = _nt.ToCharacter_nd
ToIntND = _nt.CoInteger_nd

__all__ = [
"add",
"capitalize",
Expand Down Expand Up @@ -90,46 +87,72 @@ _CoStringND: TypeAlias = _nt.ToString_nd | _nt.ToStr_nd
#
@overload
def startswith(
a: _nt.ToBytes_nd, prefix: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None
a: _nt.ToBytes_nd, prefix: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _BoolND: ...
@overload
def startswith(a: _CoStringND, prefix: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _BoolND: ...
def startswith(
a: _CoStringND, prefix: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _BoolND: ...

#
@overload
def endswith(a: _nt.ToBytes_nd, suffix: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _BoolND: ...
def endswith(
a: _nt.ToBytes_nd, suffix: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _BoolND: ...
@overload
def endswith(a: _CoStringND, suffix: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _BoolND: ...
def endswith(
a: _CoStringND, suffix: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _BoolND: ...

###

#
@overload
def find(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def find(
a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...
@overload
def find(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def find(
a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...

#
@overload
def rfind(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def rfind(
a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...
@overload
def rfind(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def rfind(
a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...

#
@overload
def index(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def index(
a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...
@overload
def index(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def index(
a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...
@overload
def rindex(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def rindex(
a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...
@overload
def rindex(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def rindex(
a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...

#
@overload
def count(a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def count(
a: _nt.ToBytes_nd, sub: _nt.ToBytes_nd, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...
@overload
def count(a: _CoStringND, sub: _CoStringND, start: ToIntND = 0, end: ToIntND | None = None) -> _IntND: ...
def count(
a: _CoStringND, sub: _CoStringND, start: _nt.CoInteger_nd = 0, end: _nt.CoInteger_nd | None = None
) -> _IntND: ...

###

Expand Down Expand Up @@ -181,51 +204,51 @@ def title(a: _nt.ToString_nd) -> _nt.StringArray: ...

#
@overload
def multiply(a: _nt.ToStr_nd, i: ToIntND) -> _StrND: ...
def multiply(a: _nt.ToStr_nd, i: _nt.CoInteger_nd) -> _StrND: ...
@overload
def multiply(a: _nt.ToBytes_nd, i: ToIntND) -> _BytesND: ...
def multiply(a: _nt.ToBytes_nd, i: _nt.CoInteger_nd) -> _BytesND: ...
@overload
def multiply(a: _nt.ToString_nd, i: ToIntND) -> _nt.StringArray: ...
def multiply(a: _nt.ToString_nd, i: _nt.CoInteger_nd) -> _nt.StringArray: ...

#
@overload
def expandtabs(a: _nt.ToStr_nd, tabsize: ToIntND = 8) -> _StrND: ...
def expandtabs(a: _nt.ToStr_nd, tabsize: _nt.CoInteger_nd = 8) -> _StrND: ...
@overload
def expandtabs(a: _nt.ToBytes_nd, tabsize: ToIntND = 8) -> _BytesND: ...
def expandtabs(a: _nt.ToBytes_nd, tabsize: _nt.CoInteger_nd = 8) -> _BytesND: ...
@overload
def expandtabs(a: _nt.ToString_nd, tabsize: ToIntND = 8) -> _nt.StringArray: ...
def expandtabs(a: _nt.ToString_nd, tabsize: _nt.CoInteger_nd = 8) -> _nt.StringArray: ...

#
@overload
def center(a: _nt.ToStr_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _StrND: ...
def center(a: _nt.ToStr_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _StrND: ...
@overload
def center(a: _nt.ToBytes_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _BytesND: ...
def center(a: _nt.ToBytes_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _BytesND: ...
@overload
def center(a: _nt.ToString_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _nt.StringArray: ...
def center(a: _nt.ToString_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _nt.StringArray: ...

#
@overload
def ljust(a: _nt.ToStr_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _StrND: ...
def ljust(a: _nt.ToStr_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _StrND: ...
@overload
def ljust(a: _nt.ToBytes_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _BytesND: ...
def ljust(a: _nt.ToBytes_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _BytesND: ...
@overload
def ljust(a: _nt.ToString_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _nt.StringArray: ...
def ljust(a: _nt.ToString_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _nt.StringArray: ...

#
@overload
def rjust(a: _nt.ToStr_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _StrND: ...
def rjust(a: _nt.ToStr_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _StrND: ...
@overload
def rjust(a: _nt.ToBytes_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _BytesND: ...
def rjust(a: _nt.ToBytes_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _BytesND: ...
@overload
def rjust(a: _nt.ToString_nd, width: ToIntND, fillchar: ToAnyStringND = " ") -> _nt.StringArray: ...
def rjust(a: _nt.ToString_nd, width: _nt.CoInteger_nd, fillchar: _nt.ToCharacter_nd = " ") -> _nt.StringArray: ...

#
@overload
def zfill(a: _nt.ToStr_nd, width: ToIntND) -> _StrND: ...
def zfill(a: _nt.ToStr_nd, width: _nt.CoInteger_nd) -> _StrND: ...
@overload
def zfill(a: _nt.ToBytes_nd, width: ToIntND) -> _BytesND: ...
def zfill(a: _nt.ToBytes_nd, width: _nt.CoInteger_nd) -> _BytesND: ...
@overload
def zfill(a: _nt.ToString_nd, width: ToIntND) -> _nt.StringArray: ...
def zfill(a: _nt.ToString_nd, width: _nt.CoInteger_nd) -> _nt.StringArray: ...

#
@overload
Expand Down Expand Up @@ -301,13 +324,17 @@ def strip(a: _CoStringND, chars: _CoStringND | None = None) -> _StrND | _nt.Stri

#
@overload
def replace(a: _nt.ToStr_nd, old: _nt.ToStr_nd, new: _nt.ToStr_nd, count: ToIntND = -1) -> _StrND: ...
def replace(a: _nt.ToStr_nd, old: _nt.ToStr_nd, new: _nt.ToStr_nd, count: _nt.CoInteger_nd = -1) -> _StrND: ...
@overload
def replace(a: _nt.ToBytes_nd, old: _nt.ToBytes_nd, new: _nt.ToBytes_nd, count: ToIntND = -1) -> _BytesND: ...
def replace(a: _nt.ToBytes_nd, old: _nt.ToBytes_nd, new: _nt.ToBytes_nd, count: _nt.CoInteger_nd = -1) -> _BytesND: ...
@overload
def replace(a: _nt.ToString_nd, old: _CoStringND, new: _CoStringND, count: ToIntND = -1) -> _nt.StringArray: ...
def replace(
a: _nt.ToString_nd, old: _CoStringND, new: _CoStringND, count: _nt.CoInteger_nd = -1
) -> _nt.StringArray: ...
@overload
def replace(a: _CoStringND, old: _CoStringND, new: _CoStringND, count: ToIntND = -1) -> _StrND | _nt.StringArray: ...
def replace(
a: _CoStringND, old: _CoStringND, new: _CoStringND, count: _nt.CoInteger_nd = -1
) -> _StrND | _nt.StringArray: ...

#
@overload
Expand Down
Loading