Skip to content
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
5 changes: 2 additions & 3 deletions pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -872,16 +872,15 @@ SeriesDType: TypeAlias = (
| datetime.timedelta # includes pd.Timedelta
)
S1 = TypeVar("S1", bound=SeriesDType, default=Any)
S1_CO_NSDT = TypeVar(
"S1_CO_NSDT", bound=SeriesDTypeNoStrDateTime, default=Any, covariant=True
)
S1_CT_NDT = TypeVar(
"S1_CT_NDT", bound=SeriesDTypeNoDateTime, default=Any, contravariant=True
)
S1_CO = TypeVar("S1_CO", bound=SeriesDType, default=Any, covariant=True)
S1_CT = TypeVar("S1_CT", bound=SeriesDType, default=Any, contravariant=True)
# Like S1, but without `default=Any`.
S2 = TypeVar("S2", bound=SeriesDType)
S2_CT = TypeVar("S2_CT", bound=SeriesDType, contravariant=True)
S2_CO_NSDT = TypeVar("S2_CO_NSDT", bound=SeriesDTypeNoStrDateTime, covariant=True)
S3 = TypeVar("S3", bound=SeriesDType)

# Constraint, instead of bound
Expand Down
51 changes: 28 additions & 23 deletions pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ from pandas._typing import (
C2,
S1,
S1_CO,
S1_CO_NSDT,
S1_CT,
S2_CO_NSDT,
S2_CT,
T_COMPLEX,
T_INT,
AnyAll,
Expand Down Expand Up @@ -753,30 +754,32 @@ class Index(IndexOpsMixin[S1]):
@overload
def __mul__(self, other: np_ndarray_dt) -> Never: ...
@overload
def __mul__(self: Index[complex], other: np_ndarray_td) -> Never: ...
def __mul__(self: Index[bool] | Index[complex], other: np_ndarray_td) -> Never: ...
# pandas-dev/pandas#62524: An index of Python native timedeltas can be
# produced, instead of a TimedeltaIndex, hence the overload
@overload
def __mul__( # type: ignore[overload-overlap]
self: Index[bool] | Index[int] | Index[float], other: Sequence[timedelta]
self: Index[int] | Index[float], other: Sequence[timedelta]
) -> Index[Timedelta]: ...
@overload
def __mul__(
self: Index[bool] | Index[int] | Index[float],
self: Index[int] | Index[float],
other: timedelta | Sequence[Timedelta] | np.timedelta64 | np_ndarray_td,
) -> TimedeltaIndex: ...
@overload
def __mul__(self: Index[Timedelta], other: np_ndarray_complex) -> Never: ...
def __mul__(
self: Index[Timedelta], other: np_ndarray_bool | np_ndarray_complex
) -> Never: ...
@overload
def __mul__(
self: Index[Timedelta],
other: (
float
| Sequence[float]
| np_ndarray_bool
Just[int]
| Just[float]
| Sequence[Just[int]]
| Sequence[Just[float]]
| np_ndarray_anyint
| np_ndarray_float
| Index[bool]
| Index[int]
| Index[float]
),
Expand Down Expand Up @@ -807,11 +810,11 @@ class Index(IndexOpsMixin[S1]):
) -> Index[complex]: ...
@overload
def __mul__(
self: Index[S1_CT],
self: Index[S2_CT],
other: (
SupportsRMul[S1_CT, S1_CO_NSDT] | Sequence[SupportsRMul[S1_CT, S1_CO_NSDT]]
SupportsRMul[S2_CT, S2_CO_NSDT] | Sequence[SupportsRMul[S2_CT, S2_CO_NSDT]]
),
) -> Index[S1_CO_NSDT]: ...
) -> Index[S2_CO_NSDT]: ...
@overload
def __mul__(
self: Index[T_COMPLEX], other: np_ndarray_bool | Index[bool]
Expand Down Expand Up @@ -843,30 +846,32 @@ class Index(IndexOpsMixin[S1]):
@overload
def __rmul__(self, other: np_ndarray_dt) -> Never: ...
@overload
def __rmul__(self: Index[complex], other: np_ndarray_td) -> Never: ...
def __rmul__(self: Index[bool] | Index[complex], other: np_ndarray_td) -> Never: ...
# pandas-dev/pandas#62524: An index of Python native timedeltas can be
# produced, instead of a TimedeltaIndex, hence the overload
@overload
def __rmul__( # type: ignore[overload-overlap]
self: Index[bool] | Index[int] | Index[float], other: Sequence[timedelta]
self: Index[int] | Index[float], other: Sequence[timedelta]
) -> Index[Timedelta]: ...
@overload
def __rmul__(
self: Index[bool] | Index[int] | Index[float],
self: Index[int] | Index[float],
other: timedelta | Sequence[Timedelta] | np.timedelta64 | np_ndarray_td,
) -> TimedeltaIndex: ...
@overload
def __rmul__(self: Index[Timedelta], other: np_ndarray_complex) -> Never: ...
def __rmul__(
self: Index[Timedelta], other: np_ndarray_bool | np_ndarray_complex
) -> Never: ...
@overload
def __rmul__(
self: Index[Timedelta],
other: (
float
| Sequence[float]
| np_ndarray_bool
Just[int]
| Just[float]
| Sequence[Just[int]]
| Sequence[Just[float]]
| np_ndarray_anyint
| np_ndarray_float
| Index[bool]
| Index[int]
| Index[float]
),
Expand Down Expand Up @@ -897,11 +902,11 @@ class Index(IndexOpsMixin[S1]):
) -> Index[complex]: ...
@overload
def __rmul__(
self: Index[S1_CT],
self: Index[S2_CT],
other: (
SupportsMul[S1_CT, S1_CO_NSDT] | Sequence[SupportsMul[S1_CT, S1_CO_NSDT]]
SupportsMul[S2_CT, S2_CO_NSDT] | Sequence[SupportsMul[S2_CT, S2_CO_NSDT]]
),
) -> Index[S1_CO_NSDT]: ...
) -> Index[S2_CO_NSDT]: ...
@overload
def __rmul__(
self: Index[T_COMPLEX], other: np_ndarray_bool | Index[bool]
Expand Down
21 changes: 11 additions & 10 deletions pandas-stubs/core/indexes/timedeltas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ from pandas._libs import Timedelta
from pandas._libs.tslibs import BaseOffset
from pandas._typing import (
AxesData,
Just,
TimedeltaConvertibleTypes,
np_ndarray_anyint,
np_ndarray_bool,
Expand Down Expand Up @@ -86,33 +87,33 @@ class TimedeltaIndex(
self, other: dt.datetime | np.datetime64 | np_ndarray_dt | DatetimeIndex
) -> DatetimeIndex: ...
@overload # type: ignore[override]
def __mul__(self, other: np_ndarray_complex) -> Never: ...
def __mul__(self, other: np_ndarray_bool | np_ndarray_complex) -> Never: ...
@overload
def __mul__(
self,
other: (
float
| Sequence[float]
| np_ndarray_bool
Just[int]
| Just[float]
| Sequence[Just[int]]
| Sequence[Just[float]]
| np_ndarray_anyint
| np_ndarray_float
| Index[bool]
| Index[int]
| Index[float]
),
) -> Self: ...
@overload # type: ignore[override]
def __rmul__(self, other: np_ndarray_complex) -> Never: ...
def __rmul__(self, other: np_ndarray_bool | np_ndarray_complex) -> Never: ...
@overload
def __rmul__(
self,
other: (
float
| Sequence[float]
| np_ndarray_bool
Just[int]
| Just[float]
| Sequence[Just[int]]
| Sequence[Just[float]]
| np_ndarray_anyint
| np_ndarray_float
| Index[bool]
| Index[int]
| Index[float]
),
Expand Down
Loading