Skip to content

Commit 646cdcd

Browse files
committed
Merge branch 'main' into feature/cmp0xff/arithmetics-for-series-any
2 parents 8d8691e + 3033eea commit 646cdcd

File tree

9 files changed

+182
-59
lines changed

9 files changed

+182
-59
lines changed

pandas-stubs/_libs/tslibs/offsets.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ class BaseOffset:
8989
@property
9090
def nanos(self) -> int: ...
9191

92-
class SingleConstructorOffset(BaseOffset):
93-
def __reduce__(self): ...
92+
class SingleConstructorOffset(BaseOffset): ...
9493

9594
class Tick(SingleConstructorOffset):
9695
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...

pandas-stubs/_typing.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ IndexingInt: TypeAlias = (
893893
)
894894

895895
# AxesData is used for data for Index
896-
AxesData: TypeAlias = Mapping[S3, Any] | Axes | KeysView
896+
AxesData: TypeAlias = Mapping[S3, Any] | Axes | KeysView[S3]
897897

898898
# Any plain Python or numpy function
899899
Function: TypeAlias = np.ufunc | Callable[..., Any]

pandas-stubs/core/frame.pyi

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,16 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
545545
@classmethod
546546
def from_records(
547547
cls,
548-
data,
549-
index=...,
550-
exclude: SequenceNotStr[str] | None = None,
551-
columns: SequenceNotStr[str] | None = None,
548+
data: (
549+
np_2darray
550+
| Sequence[SequenceNotStr]
551+
| Sequence[Mapping[str, Any]]
552+
| Mapping[str, Any]
553+
| Mapping[str, SequenceNotStr[Any]]
554+
),
555+
index: str | SequenceNotStr[Hashable] | None = None,
556+
columns: ListLike | None = None,
557+
exclude: ListLike | None = None,
552558
coerce_float: bool = False,
553559
nrows: int | None = None,
554560
) -> Self: ...

pandas-stubs/core/indexes/base.pyi

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ from pandas._typing import (
5050
ArrayLike,
5151
AxesData,
5252
DropKeep,
53+
Dtype,
5354
DtypeArg,
5455
DTypeLike,
5556
DtypeObj,
@@ -89,7 +90,6 @@ class Index(IndexOpsMixin[S1]):
8990
copy: bool = ...,
9091
name: Hashable = ...,
9192
tupleize_cols: bool = ...,
92-
**kwargs,
9393
) -> Index[int]: ...
9494
@overload
9595
def __new__(
@@ -100,7 +100,6 @@ class Index(IndexOpsMixin[S1]):
100100
copy: bool = ...,
101101
name: Hashable = ...,
102102
tupleize_cols: bool = ...,
103-
**kwargs,
104103
) -> Index[int]: ...
105104
@overload
106105
def __new__(
@@ -111,7 +110,6 @@ class Index(IndexOpsMixin[S1]):
111110
copy: bool = ...,
112111
name: Hashable = ...,
113112
tupleize_cols: bool = ...,
114-
**kwargs,
115113
) -> Index[float]: ...
116114
@overload
117115
def __new__(
@@ -122,7 +120,6 @@ class Index(IndexOpsMixin[S1]):
122120
copy: bool = ...,
123121
name: Hashable = ...,
124122
tupleize_cols: bool = ...,
125-
**kwargs,
126123
) -> Index[float]: ...
127124
@overload
128125
def __new__(
@@ -137,7 +134,6 @@ class Index(IndexOpsMixin[S1]):
137134
copy: bool = ...,
138135
name: Hashable = ...,
139136
tupleize_cols: bool = ...,
140-
**kwargs,
141137
) -> Index[complex]: ...
142138
@overload
143139
def __new__(
@@ -148,7 +144,6 @@ class Index(IndexOpsMixin[S1]):
148144
copy: bool = ...,
149145
name: Hashable = ...,
150146
tupleize_cols: bool = ...,
151-
**kwargs,
152147
) -> Index[complex]: ...
153148
# special overloads with dedicated Index-subclasses
154149
@overload
@@ -160,7 +155,6 @@ class Index(IndexOpsMixin[S1]):
160155
copy: bool = ...,
161156
name: Hashable = ...,
162157
tupleize_cols: bool = ...,
163-
**kwargs,
164158
) -> DatetimeIndex: ...
165159
@overload
166160
def __new__(
@@ -171,7 +165,6 @@ class Index(IndexOpsMixin[S1]):
171165
copy: bool = ...,
172166
name: Hashable = ...,
173167
tupleize_cols: bool = ...,
174-
**kwargs,
175168
) -> DatetimeIndex: ...
176169
@overload
177170
def __new__(
@@ -182,7 +175,6 @@ class Index(IndexOpsMixin[S1]):
182175
copy: bool = ...,
183176
name: Hashable = ...,
184177
tupleize_cols: bool = ...,
185-
**kwargs,
186178
) -> PeriodIndex: ...
187179
@overload
188180
def __new__(
@@ -193,7 +185,6 @@ class Index(IndexOpsMixin[S1]):
193185
copy: bool = ...,
194186
name: Hashable = ...,
195187
tupleize_cols: bool = ...,
196-
**kwargs,
197188
) -> PeriodIndex: ...
198189
@overload
199190
def __new__(
@@ -204,7 +195,6 @@ class Index(IndexOpsMixin[S1]):
204195
copy: bool = ...,
205196
name: Hashable = ...,
206197
tupleize_cols: bool = ...,
207-
**kwargs,
208198
) -> TimedeltaIndex: ...
209199
@overload
210200
def __new__(
@@ -215,7 +205,6 @@ class Index(IndexOpsMixin[S1]):
215205
copy: bool = ...,
216206
name: Hashable = ...,
217207
tupleize_cols: bool = ...,
218-
**kwargs,
219208
) -> TimedeltaIndex: ...
220209
@overload
221210
def __new__(
@@ -226,7 +215,6 @@ class Index(IndexOpsMixin[S1]):
226215
copy: bool = ...,
227216
name: Hashable = ...,
228217
tupleize_cols: bool = ...,
229-
**kwargs,
230218
) -> IntervalIndex[Interval[_OrderableT]]: ...
231219
@overload
232220
def __new__(
@@ -237,7 +225,6 @@ class Index(IndexOpsMixin[S1]):
237225
copy: bool = ...,
238226
name: Hashable = ...,
239227
tupleize_cols: bool = ...,
240-
**kwargs,
241228
) -> IntervalIndex[Interval[Any]]: ...
242229
# generic overloads
243230
@overload
@@ -249,7 +236,6 @@ class Index(IndexOpsMixin[S1]):
249236
copy: bool = ...,
250237
name: Hashable = ...,
251238
tupleize_cols: bool = ...,
252-
**kwargs,
253239
) -> Self: ...
254240
@overload
255241
def __new__(
@@ -260,19 +246,17 @@ class Index(IndexOpsMixin[S1]):
260246
copy: bool = ...,
261247
name: Hashable = ...,
262248
tupleize_cols: bool = ...,
263-
**kwargs,
264249
) -> Self: ...
265250
# fallback overload
266251
@overload
267252
def __new__(
268253
cls,
269254
data: AxesData,
270255
*,
271-
dtype=...,
256+
dtype: Dtype = ...,
272257
copy: bool = ...,
273258
name: Hashable = ...,
274259
tupleize_cols: bool = ...,
275-
**kwargs,
276260
) -> Self: ...
277261
@property
278262
def str(

pandas-stubs/core/indexes/period.pyi

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections.abc import Hashable
22
import datetime
33
from typing import (
4-
final,
4+
Any,
55
overload,
66
)
77

@@ -14,27 +14,28 @@ from pandas.core.indexes.timedeltas import TimedeltaIndex
1414
from typing_extensions import Self
1515

1616
from pandas._libs.tslibs import (
17-
BaseOffset,
1817
NaTType,
1918
Period,
2019
)
2120
from pandas._libs.tslibs.period import _PeriodAddSub
21+
from pandas._typing import (
22+
AxesData,
23+
Dtype,
24+
Frequency,
25+
np_1darray,
26+
)
2227

2328
class PeriodIndex(DatetimeIndexOpsMixin[pd.Period, np.object_], PeriodIndexFieldOps):
2429
def __new__(
2530
cls,
26-
data=...,
27-
ordinal=...,
28-
freq=...,
29-
tz=...,
30-
dtype=...,
31-
copy: bool = ...,
32-
name: Hashable = ...,
33-
**fields,
34-
): ...
31+
data: AxesData[Any] | None = None,
32+
freq: Frequency | None = None,
33+
dtype: Dtype | None = None,
34+
copy: bool = False,
35+
name: Hashable | None = None,
36+
) -> Self: ...
3537
@property
36-
def values(self): ...
37-
def __contains__(self, key) -> bool: ...
38+
def values(self) -> np_1darray[np.object_]: ...
3839
@overload
3940
def __sub__(self, other: Period) -> Index: ...
4041
@overload
@@ -53,31 +54,18 @@ class PeriodIndex(DatetimeIndexOpsMixin[pd.Period, np.object_], PeriodIndexField
5354
def __rsub__( # pyright: ignore[reportIncompatibleMethodOverride]
5455
self, other: NaTType
5556
) -> NaTType: ...
56-
@final
57-
def __array_wrap__(self, result, context=...): ...
58-
def asof_locs(self, where, mask): ...
59-
def searchsorted(self, value, side: str = ..., sorter=...): ...
57+
def asof_locs(
58+
self,
59+
where: pd.DatetimeIndex | PeriodIndex,
60+
mask: np_1darray[np.bool_],
61+
) -> np_1darray[np.intp]: ...
6062
@property
6163
def is_full(self) -> bool: ...
6264
@property
6365
def inferred_type(self) -> str: ...
64-
@final
65-
def get_indexer(self, target, method=..., limit=..., tolerance=...): ...
66-
def get_indexer_non_unique(self, target): ...
67-
def insert(self, loc, item): ...
68-
@final
69-
def join(
70-
self,
71-
other,
72-
*,
73-
how: str = ...,
74-
level=...,
75-
return_indexers: bool = ...,
76-
sort: bool = ...,
77-
): ...
7866
@property
7967
def freqstr(self) -> str: ...
80-
def shift(self, periods: int = 1, freq=...) -> Self: ...
68+
def shift(self, periods: int = 1, freq: Frequency | None = None) -> Self: ...
8169

8270
def period_range(
8371
start: (
@@ -87,6 +75,6 @@ def period_range(
8775
str | datetime.datetime | datetime.date | pd.Timestamp | pd.Period | None
8876
) = None,
8977
periods: int | None = None,
90-
freq: str | BaseOffset | None = None,
78+
freq: Frequency | None = None,
9179
name: Hashable | None = None,
9280
) -> PeriodIndex: ...

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ xarray = ">=22.6.0"
6161
tabulate = ">=0.8.10"
6262
jinja2 = ">=3.1"
6363
scipy = { version = ">=1.9.1", python = "<3.14" }
64+
scipy-stubs = ">=1.15.3.0"
6465
SQLAlchemy = ">=2.0.39"
6566
types-python-dateutil = ">=2.8.19"
6667
beautifulsoup4 = ">=4.12.2"

tests/series/arithmetic/test_sub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import pandas as pd
1010
import pytest
1111
from typing_extensions import (
12+
Never,
1213
assert_never,
1314
assert_type,
14-
Never
1515
)
1616

1717
from tests import (

0 commit comments

Comments
 (0)