Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TYP: simplify redundant unions of builtin scalar types #28819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion numpy/_core/fromnumeric.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class _SupportsShape(Protocol[_ShapeT_co]):
_T = TypeVar("_T")
_PyArray: TypeAlias = list[_T] | tuple[_T, ...]
# `int` also covers `bool`
_PyScalar: TypeAlias = float | complex | bytes | str
_PyScalar: TypeAlias = complex | bytes | str

@overload
def take(
Expand Down
4 changes: 1 addition & 3 deletions numpy/_core/numeric.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,7 @@ def fromfunction(
**kwargs: Any,
) -> _T: ...

def isscalar(element: object) -> TypeGuard[
generic | bool | int | float | complex | str | bytes | memoryview
]: ...
def isscalar(element: object) -> TypeGuard[generic | complex | str | bytes | memoryview]: ...

def binary_repr(num: SupportsIndex, width: int | None = ...) -> str: ...

Expand Down
22 changes: 11 additions & 11 deletions numpy/lib/_twodim_base_impl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ def histogram2d(
]: ...
@overload
def histogram2d(
x: _ArrayLike1DInt_co | Sequence[float | int],
y: _ArrayLike1DInt_co | Sequence[float | int],
x: _ArrayLike1DInt_co | Sequence[float],
y: _ArrayLike1DInt_co | Sequence[float],
bins: int | Sequence[int] = ...,
range: _ArrayLike2DFloat_co | None = ...,
density: bool | None = ...,
Expand All @@ -282,8 +282,8 @@ def histogram2d(
]: ...
@overload
def histogram2d(
x: Sequence[complex | float | int],
y: Sequence[complex | float | int],
x: Sequence[complex],
y: Sequence[complex],
bins: int | Sequence[int] = ...,
range: _ArrayLike2DFloat_co | None = ...,
density: bool | None = ...,
Expand Down Expand Up @@ -321,8 +321,8 @@ def histogram2d(
]: ...
@overload
def histogram2d(
x: _ArrayLike1DInt_co | Sequence[float | int],
y: _ArrayLike1DInt_co | Sequence[float | int],
x: _ArrayLike1DInt_co | Sequence[float],
y: _ArrayLike1DInt_co | Sequence[float],
bins: Sequence[_ArrayLike1D[_NumberCoT] | int],
range: _ArrayLike2DFloat_co | None = ...,
density: bool | None = ...,
Expand All @@ -334,8 +334,8 @@ def histogram2d(
]: ...
@overload
def histogram2d(
x: Sequence[complex | float | int],
y: Sequence[complex | float | int],
x: Sequence[complex],
y: Sequence[complex],
bins: Sequence[_ArrayLike1D[_NumberCoT] | int],
range: _ArrayLike2DFloat_co | None = ...,
density: bool | None = ...,
Expand All @@ -362,7 +362,7 @@ def histogram2d(
def histogram2d(
x: _ArrayLike1DNumber_co,
y: _ArrayLike1DNumber_co,
bins: Sequence[Sequence[int | bool]],
bins: Sequence[Sequence[int]],
range: _ArrayLike2DFloat_co | None = ...,
density: bool | None = ...,
weights: _ArrayLike1DFloat_co | None = ...,
Expand All @@ -375,7 +375,7 @@ def histogram2d(
def histogram2d(
x: _ArrayLike1DNumber_co,
y: _ArrayLike1DNumber_co,
bins: Sequence[Sequence[float | int | bool]],
bins: Sequence[Sequence[float]],
range: _ArrayLike2DFloat_co | None = ...,
density: bool | None = ...,
weights: _ArrayLike1DFloat_co | None = ...,
Expand All @@ -388,7 +388,7 @@ def histogram2d(
def histogram2d(
x: _ArrayLike1DNumber_co,
y: _ArrayLike1DNumber_co,
bins: Sequence[Sequence[complex | float | int | bool]],
bins: Sequence[Sequence[complex]],
range: _ArrayLike2DFloat_co | None = ...,
density: bool | None = ...,
weights: _ArrayLike1DFloat_co | None = ...,
Expand Down
6 changes: 3 additions & 3 deletions numpy/typing/tests/data/reveal/dtype.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ dtype_U: np.dtype[np.str_]
dtype_V: np.dtype[np.void]
dtype_i8: np.dtype[np.int64]

py_int_co: type[int | bool]
py_float_co: type[float | int | bool]
py_complex_co: type[complex | float | int | bool]
py_int_co: type[int]
py_float_co: type[float]
py_complex_co: type[complex]
py_object: type[_PyObjectLike]
py_character: type[str | bytes]
py_flexible: type[str | bytes | memoryview]
Expand Down
Loading