Skip to content

Commit 761b272

Browse files
Merge branch 'main' of github.com:loicdiridollou/pandas-stubs into ghxxx_cleanup_ann
2 parents 5532e53 + 6d02ca8 commit 761b272

32 files changed

+202
-190
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ci:
33
autofix_prs: false
44
repos:
55
- repo: https://github.com/astral-sh/ruff-pre-commit
6-
rev: v0.14.3
6+
rev: v0.14.9
77
hooks:
88
- id: ruff-check
99
args: [--exit-non-zero-on-fix]
@@ -18,6 +18,6 @@ repos:
1818
hooks:
1919
- id: isort
2020
- repo: https://github.com/psf/black
21-
rev: 25.9.0
21+
rev: 25.12.0
2222
hooks:
2323
- id: black

pandas-stubs/_typing.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,10 @@ np_1darray_dt: TypeAlias = np_1darray[np.datetime64]
959959
np_1darray_td: TypeAlias = np_1darray[np.timedelta64]
960960
np_2darray: TypeAlias = np.ndarray[tuple[int, int], np.dtype[GenericT]]
961961

962-
NDArrayT = TypeVar("NDArrayT", bound=np.ndarray)
962+
if sys.version_info >= (3, 11):
963+
NDArrayT = TypeVar("NDArrayT", bound=np.ndarray)
964+
else:
965+
NDArrayT = TypeVar("NDArrayT", bound=np.ndarray[Any, Any])
963966

964967
DtypeNp = TypeVar("DtypeNp", bound=np.dtype[np.generic])
965968
KeysArgType: TypeAlias = Any

pandas-stubs/core/base.pyi

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
from collections.abc import (
2-
Callable,
3-
Hashable,
42
Iterator,
53
Sequence,
64
)
@@ -12,7 +10,6 @@ from typing import (
1210
Protocol,
1311
TypeAlias,
1412
TypeVar,
15-
final,
1613
overload,
1714
type_check_only,
1815
)
@@ -43,7 +40,6 @@ from pandas._typing import (
4340
GenericT_co,
4441
Just,
4542
ListLike,
46-
NDFrameT,
4743
Scalar,
4844
SupportsDType,
4945
np_1darray,
@@ -55,22 +51,12 @@ from pandas._typing import (
5551
np_ndarray_float,
5652
np_ndarray_td,
5753
)
58-
from pandas.util._decorators import cache_readonly
5954

6055
T_INTERVAL_NP = TypeVar("T_INTERVAL_NP", bound=np.bytes_ | np.str_)
6156

6257
class NoNewAttributesMixin:
6358
def __setattr__(self, key: str, value: Any) -> None: ...
6459

65-
class SelectionMixin(Generic[NDFrameT]):
66-
obj: NDFrameT
67-
exclusions: frozenset[Hashable]
68-
@final
69-
@cache_readonly
70-
def ndim(self) -> int: ...
71-
def __getitem__(self, key: Any) -> Any: ...
72-
def aggregate(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ...
73-
7460
class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
7561
__array_priority__: int = ...
7662
@property

pandas-stubs/core/frame.pyi

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -340,28 +340,23 @@ class _AtIndexerFrame(_AtIndexer):
340340
value: Scalar | NAType | NaTType | None,
341341
) -> None: ...
342342

343-
# With mypy 1.14.1 and python 3.12, the second overload needs a type-ignore statement
344-
if sys.version_info >= (3, 12):
345-
class _GetItemHack:
346-
@overload
347-
def __getitem__(self, key: Scalar | tuple[Hashable, ...]) -> Series: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
343+
class _GetItemHack:
344+
@overload
345+
def __getitem__(self, key: Scalar | tuple[Hashable, ...]) -> Series: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
346+
# With python 3.12+, the second overload needs a type-ignore statement
347+
if sys.version_info >= (3, 12):
348348
@overload
349349
def __getitem__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
350350
self, key: Iterable[Hashable] | slice
351351
) -> Self: ...
352-
@overload
353-
def __getitem__(self, key: Hashable) -> Series: ...
354-
355-
else:
356-
class _GetItemHack:
357-
@overload
358-
def __getitem__(self, key: Scalar | tuple[Hashable, ...]) -> Series: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
352+
else:
359353
@overload
360354
def __getitem__( # pyright: ignore[reportOverlappingOverload]
361355
self, key: Iterable[Hashable] | slice
362356
) -> Self: ...
363-
@overload
364-
def __getitem__(self, key: Hashable) -> Series: ...
357+
358+
@overload
359+
def __getitem__(self, key: Hashable) -> Series: ...
365360

366361
_AstypeArgExt: TypeAlias = (
367362
AstypeArg
@@ -562,16 +557,29 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
562557
coerce_float: bool = False,
563558
nrows: int | None = None,
564559
) -> Self: ...
565-
def to_records(
566-
self,
567-
index: _bool = True,
568-
column_dtypes: (
569-
_str | npt.DTypeLike | Mapping[HashableT1, npt.DTypeLike] | None
570-
) = None,
571-
index_dtypes: (
572-
_str | npt.DTypeLike | Mapping[HashableT2, npt.DTypeLike] | None
573-
) = None,
574-
) -> np.recarray: ...
560+
if sys.version_info >= (3, 11):
561+
def to_records(
562+
self,
563+
index: _bool = True,
564+
column_dtypes: (
565+
_str | npt.DTypeLike | Mapping[HashableT1, npt.DTypeLike] | None
566+
) = None,
567+
index_dtypes: (
568+
_str | npt.DTypeLike | Mapping[HashableT2, npt.DTypeLike] | None
569+
) = None,
570+
) -> np.recarray: ...
571+
else:
572+
def to_records(
573+
self,
574+
index: _bool = True,
575+
column_dtypes: (
576+
_str | npt.DTypeLike | Mapping[HashableT1, npt.DTypeLike] | None
577+
) = None,
578+
index_dtypes: (
579+
_str | npt.DTypeLike | Mapping[HashableT2, npt.DTypeLike] | None
580+
) = None,
581+
) -> np.recarray[Any, Any]: ...
582+
575583
@overload
576584
def to_stata(
577585
self,

pandas-stubs/core/groupby/groupby.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ from typing import (
1818
)
1919

2020
import numpy as np
21-
from pandas.core.base import SelectionMixin
2221
from pandas.core.frame import DataFrame
2322
from pandas.core.groupby import generic
2423
from pandas.core.groupby.indexing import (
@@ -350,7 +349,7 @@ class GroupByPlot(PlotAccessor, Generic[_GroupByT]):
350349
# def __call__(self, *args: Any, **kwargs: Any): ...
351350
# def __getattr__(self, name: str): ...
352351

353-
class BaseGroupBy(SelectionMixin[NDFrameT], GroupByIndexingMixin):
352+
class BaseGroupBy(GroupByIndexingMixin, Generic[NDFrameT]):
354353
@final
355354
def __len__(self) -> int: ...
356355
@final

pandas-stubs/core/groupby/ops.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from collections.abc import (
2-
Iterator,
3-
)
1+
from collections.abc import Iterator
42
from typing import Generic
53

64
from pandas._typing import (

pandas-stubs/core/indexes/multi.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ class MultiIndex(Index):
144144
@overload
145145
def unique( # ty: ignore[invalid-method-override] # pyright: ignore[reportIncompatibleMethodOverride]
146146
self, level: Level
147-
) -> (
148-
Index
149-
): ... # ty: ignore[invalid-method-override] # pyrefly: ignore[bad-override]
147+
) -> Index: ...
150148
def to_frame( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
151149
self,
152150
index: bool = True,
@@ -174,7 +172,7 @@ class MultiIndex(Index):
174172
@overload
175173
def append( # pyright: ignore[reportIncompatibleMethodOverride]
176174
self, other: Index | Sequence[Index]
177-
) -> Index: ... # pyrefly: ignore[bad-override]
175+
) -> Index: ...
178176
def drop(self, codes: Level | Sequence[Level], level: Level | None = None, errors: str = "raise") -> MultiIndex: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
179177
def swaplevel(self, i: int = -2, j: int = -1) -> Self: ...
180178
def reorder_levels(self, order: Sequence[Level]) -> MultiIndex: ...

pandas-stubs/core/indexes/range.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class RangeIndex(_IndexSubclassBase[int, np.int64]):
6666
def is_monotonic_decreasing(self) -> bool: ...
6767
@property
6868
def has_duplicates(self) -> bool: ...
69-
def factorize( # ty: ignore[invalid-method-override]
69+
def factorize(
7070
self, sort: bool = False, use_na_sentinel: bool = True
7171
) -> tuple[np_1darray_intp, RangeIndex]: ...
7272
@property

pandas-stubs/core/series.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,11 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
563563
self, ufunc: Callable[..., Any], method: _str, *inputs: Any, **kwargs: Any
564564
) -> Any: ...
565565
if sys.version_info >= (3, 11):
566-
def __array__( # ty: ignore[invalid-method-override]
566+
def __array__(
567567
self, dtype: _str | np.dtype = ..., copy: bool | None = ...
568568
) -> np_1darray: ...
569569
else:
570-
def __array__( # ty: ignore[invalid-method-override]
570+
def __array__(
571571
self, dtype: _str | np.dtype[Any] = ..., copy: bool | None = ...
572572
) -> np_1darray: ...
573573

pandas-stubs/core/window/ewm.pyi

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Any
2-
31
from pandas import (
42
DataFrame,
53
Series,
@@ -47,29 +45,3 @@ class ExponentialMovingWindow(BaseWindow[NDFrameT]):
4745
class ExponentialMovingWindowGroupby(
4846
BaseWindowGroupby[NDFrameT], ExponentialMovingWindow[NDFrameT]
4947
): ...
50-
51-
class OnlineExponentialMovingWindow(ExponentialMovingWindow[NDFrameT]):
52-
def reset(self) -> None: ...
53-
def aggregate(self, func, *args: Any, **kwargs: Any): ...
54-
def std(self, bias: bool = False, *args: Any, **kwargs: Any): ...
55-
def corr(
56-
self,
57-
other: DataFrame | Series | None = None,
58-
pairwise: bool | None = None,
59-
numeric_only: bool = False,
60-
): ...
61-
def cov(
62-
self,
63-
other: DataFrame | Series | None = None,
64-
pairwise: bool | None = None,
65-
bias: bool = False,
66-
numeric_only: bool = False,
67-
): ...
68-
def var(self, bias: bool = False, numeric_only: bool = False): ...
69-
def mean(
70-
self,
71-
*args: Any,
72-
update: NDFrameT | None = ...,
73-
update_times: None = None,
74-
**kwargs: Any,
75-
) -> NDFrameT: ...

0 commit comments

Comments
 (0)