Skip to content

Commit 21e867e

Browse files
committed
Merge branch 'main' into feature/cmp0xff/drop-interval-series
2 parents 984cff5 + c889b1d commit 21e867e

File tree

9 files changed

+46
-36
lines changed

9 files changed

+46
-36
lines changed

pandas-stubs/_libs/tslibs/period.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ from pandas import (
1212
Timedelta,
1313
TimedeltaIndex,
1414
)
15-
from pandas.core.series import OffsetSeries
1615
from typing_extensions import TypeAlias
1716

1817
from pandas._libs.tslibs import NaTType
@@ -95,7 +94,7 @@ class Period(PeriodMixin):
9594
def __add__(self, other: Index) -> PeriodIndex: ...
9695
@overload
9796
def __add__(
98-
self, other: OffsetSeries | Series[Timedelta]
97+
self, other: Series[BaseOffset] | Series[Timedelta]
9998
) -> Series[Period]: ... # pyrefly: ignore[bad-specialization]
10099
# ignore[misc] here because we know all other comparisons
101100
# are False, so we use Literal[False]

pandas-stubs/core/arrays/categorical.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class Categorical(ExtensionArray):
9696
@property
9797
def nbytes(self) -> int: ...
9898
def memory_usage(self, deep: bool = ...): ...
99-
def searchsorted(self, value, side: str = ..., sorter=...): ...
10099
def isna(self) -> np_1darray[np.bool]: ...
101100
def isnull(self) -> np_1darray[np.bool]: ...
102101
def notna(self) -> np_1darray[np.bool]: ...

pandas-stubs/core/arrays/datetimelike.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class DatetimeLikeArrayMixin(ExtensionOpsMixin, ExtensionArray):
8484
def unique(self): ...
8585
def copy(self): ...
8686
def shift(self, periods: int = 1, fill_value=..., axis: int = ...): ...
87-
def searchsorted(self, value, side: str = ..., sorter=...): ...
8887
def repeat(self, repeats, *args, **kwargs): ... # pyrefly: ignore
8988
def value_counts(self, dropna: bool = True): ...
9089
def map(self, mapper): ...

pandas-stubs/core/indexes/base.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ class Index(IndexOpsMixin[S1]):
323323
self, name: bool = ..., formatter: Callable | None = ..., na_rep: _str = ...
324324
) -> list[_str]: ...
325325
def to_flat_index(self): ...
326-
def to_series(self, index=..., name: Hashable = ...) -> Series[S1]: ...
326+
def to_series(
327+
self, index: Index | None = None, name: Hashable | None = None
328+
) -> Series[S1]: ...
327329
def to_frame(self, index: bool = True, name=...) -> DataFrame: ...
328330
@property
329331
def name(self) -> Hashable | None: ...

pandas-stubs/core/indexes/datetimes.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ class DatetimeIndex(
7777
self, other: datetime | np.datetime64 | np_ndarray_dt | DatetimeIndex
7878
) -> TimedeltaIndex: ...
7979
@final
80-
def to_series(self, index=..., name: Hashable = ...) -> Series[Timestamp]: ...
80+
def to_series(
81+
self, index: Index | None = None, name: Hashable | None = None
82+
) -> Series[Timestamp]: ...
8183
def snap(self, freq: str = ...): ...
8284
def slice_indexer(self, start=..., end=..., step=...): ...
83-
def searchsorted(self, value, side: str = ..., sorter=...): ...
8485
@property
8586
def inferred_type(self) -> str: ...
8687
def indexer_at_time(self, time, asof: bool = ...): ...

pandas-stubs/core/indexes/timedeltas.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ class TimedeltaIndex(
8181
self, other: dt.timedelta | Sequence[dt.timedelta]
8282
) -> Index[int]: ...
8383
def __rfloordiv__(self, other: dt.timedelta | Sequence[dt.timedelta]) -> Index[int]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
84-
def searchsorted(self, value, side: str = ..., sorter=...): ...
8584
@property
8685
def inferred_type(self) -> str: ...
8786
@final
88-
def to_series(self, index=..., name: Hashable = ...) -> Series[Timedelta]: ...
87+
def to_series(
88+
self, index: Index | None = None, name: Hashable | None = None
89+
) -> Series[Timedelta]: ...
8990
def shift(self, periods: int = 1, freq=...) -> Self: ...
9091

9192
@overload

pandas-stubs/core/series.pyi

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,15 @@ class Series(IndexOpsMixin[S1], NDFrame):
368368
copy: bool = ...,
369369
) -> Series[Period]: ...
370370
@overload
371+
def __new__(
372+
cls,
373+
data: Sequence[BaseOffset],
374+
index: AxesData | None = ...,
375+
dtype: PeriodDtype = ...,
376+
name: Hashable = ...,
377+
copy: bool = ...,
378+
) -> Series[BaseOffset]: ...
379+
@overload
371380
def __new__(
372381
cls,
373382
data: (
@@ -848,8 +857,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
848857
self: Series[BooleanDtype], periods: int = ...
849858
) -> Series[BooleanDtype]: ...
850859
@overload
851-
def diff(self: Series[Period], periods: int = ...) -> OffsetSeries: ...
852-
@overload
853860
def diff(self: Series[Interval], periods: int = ...) -> Never: ...
854861
@overload
855862
def diff(
@@ -1065,7 +1072,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
10651072
convertDType: _bool = ...,
10661073
args: tuple = ...,
10671074
**kwargs: Any,
1068-
) -> OffsetSeries: ...
1075+
) -> Series[BaseOffset]: ...
10691076
@overload
10701077
def apply(
10711078
self,
@@ -2018,6 +2025,10 @@ class Series(IndexOpsMixin[S1], NDFrame):
20182025
other: _str | Sequence[_str] | np_ndarray_str | Index[_str] | Series[_str],
20192026
) -> Series[_str]: ...
20202027
@overload
2028+
def __radd__(self: Series[BaseOffset], other: Period) -> Series[Period]: ...
2029+
@overload
2030+
def __radd__(self: Series[BaseOffset], other: BaseOffset) -> Series[BaseOffset]: ...
2031+
@overload
20212032
def radd(
20222033
self: Series[Never],
20232034
other: complex | _ListLike | Index | Series,
@@ -4670,6 +4681,22 @@ class Series(IndexOpsMixin[S1], NDFrame):
46704681
**kwargs,
46714682
) -> np_1darray[np.int64]: ...
46724683
@overload
4684+
def to_numpy(
4685+
self: Series[BaseOffset],
4686+
dtype: None = None,
4687+
copy: bool = False,
4688+
na_value: Scalar = ...,
4689+
**kwargs,
4690+
) -> np_1darray[np.object_]: ...
4691+
@overload
4692+
def to_numpy(
4693+
self: Series[BaseOffset],
4694+
dtype: type[np.bytes_],
4695+
copy: bool = False,
4696+
na_value: Scalar = ...,
4697+
**kwargs,
4698+
) -> np_1darray[np.bytes_]: ...
4699+
@overload
46734700
def to_numpy(
46744701
self: Series[Interval],
46754702
dtype: type[np.object_] | None = None,
@@ -4778,11 +4805,3 @@ class _SeriesSubclassBase(Series[S1], Generic[S1, GenericT_co]):
47784805
na_value: Scalar = ...,
47794806
**kwargs,
47804807
) -> np_1darray: ...
4781-
4782-
class OffsetSeries(_SeriesSubclassBase[BaseOffset, np.object_]):
4783-
@overload # type: ignore[override]
4784-
def __radd__(self, other: Period) -> Series[Period]: ...
4785-
@overload
4786-
def __radd__( # pyright: ignore[reportIncompatibleMethodOverride]
4787-
self, other: BaseOffset
4788-
) -> OffsetSeries: ...

tests/series/test_series.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@
7272
)
7373

7474
if TYPE_CHECKING:
75-
from pandas.core.series import OffsetSeries
76-
7775
from tests import (
7876
BooleanDtypeArg,
7977
BytesDtypeArg,
@@ -89,9 +87,6 @@
8987
VoidDtypeArg,
9088
)
9189

92-
else:
93-
OffsetSeries: TypeAlias = pd.Series
94-
9590
if not PD_LTE_23:
9691
from pandas.errors import Pandas4Warning # type: ignore[attr-defined] # pyright: ignore # isort: skip
9792
else:
@@ -3487,7 +3482,7 @@ def test_diff() -> None:
34873482
pd.Series(
34883483
pd.period_range(start="2017-01-01", end="2017-02-01", freq="D")
34893484
).diff(),
3490-
"OffsetSeries",
3485+
"pd.Series[BaseOffset]",
34913486
),
34923487
pd.Series,
34933488
BaseOffset,
@@ -3499,7 +3494,7 @@ def test_diff() -> None:
34993494
pd.Series(
35003495
pd.period_range(start="2017-01-01", end="2017-02-01", freq="D")
35013496
).diff(),
3502-
"OffsetSeries",
3497+
"pd.Series[BaseOffset]",
35033498
),
35043499
pd.Series,
35053500
BaseOffset,
@@ -3676,7 +3671,9 @@ def test_apply_dateoffset() -> None:
36763671
months = [1, 2, 3]
36773672
s = pd.Series(months)
36783673
check(
3679-
assert_type(s.apply(lambda x: pd.DateOffset(months=x)), "OffsetSeries"),
3674+
assert_type(
3675+
s.apply(lambda x: pd.DateOffset(months=x)), "pd.Series[BaseOffset]"
3676+
),
36803677
pd.Series,
36813678
pd.DateOffset,
36823679
)

tests/test_timefuncs.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import datetime as dt
44
from typing import (
5-
TYPE_CHECKING,
65
Optional,
7-
cast,
86
)
97

108
from dateutil.relativedelta import (
@@ -49,9 +47,6 @@
4947
Day,
5048
)
5149

52-
if TYPE_CHECKING:
53-
from pandas.core.series import OffsetSeries
54-
5550
if not PD_LTE_23:
5651
from pandas.errors import Pandas4Warning # type: ignore[attr-defined] # pyright: ignore # isort: skip
5752
else:
@@ -937,9 +932,7 @@ def test_series_types_to_numpy() -> None:
937932
td_s = pd.to_timedelta(pd.Series([10, 20]), "minutes")
938933
ts_s = pd.to_datetime(pd.Series(["2020-01-01", "2020-01-02"]))
939934
p_s = pd.Series(pd.period_range("2012-1-1", periods=10, freq="D"))
940-
o_s = cast(
941-
"OffsetSeries", pd.Series([pd.DateOffset(days=1), pd.DateOffset(days=2)])
942-
)
935+
o_s = pd.Series([pd.DateOffset(days=1), pd.DateOffset(days=2)])
943936
i_s = pd.interval_range(1, 2).to_series()
944937

945938
# default dtype

0 commit comments

Comments
 (0)