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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ci:
autofix_prs: false
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.0
rev: v0.14.1
hooks:
- id: ruff-check
args: [--exit-non-zero-on-fix]
Expand Down
6 changes: 4 additions & 2 deletions pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,10 @@ SeriesDType: TypeAlias = (
S1 = TypeVar("S1", bound=SeriesDType, default=Any)
# Like S1, but without `default=Any`.
S2 = TypeVar("S2", bound=SeriesDType)
S2_CT = TypeVar("S2_CT", bound=SeriesDType, contravariant=True)
S2_CT_NDT = TypeVar("S2_CT_NDT", bound=SeriesDTypeNoDateTime, contravariant=True)
S2_contra = TypeVar("S2_contra", bound=SeriesDType, contravariant=True)
S2_NDT_contra = TypeVar(
"S2_NDT_contra", bound=SeriesDTypeNoDateTime, contravariant=True
)
S2_NSDT = TypeVar("S2_NSDT", bound=SeriesDTypeNoStrDateTime)
S3 = TypeVar("S3", bound=SeriesDType)

Expand Down
14 changes: 6 additions & 8 deletions pandas-stubs/core/arrays/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ from typing import (
)

import numpy as np
from pandas import (
Index,
Series,
)
from pandas.core.arrays.base import ExtensionArray as ExtensionArray
from pandas.core.indexes.base import Index
from pandas.core.series import Series
from typing_extensions import Self

from pandas._libs.interval import (
Expand All @@ -32,15 +30,15 @@ class IntervalArray(IntervalMixin, ExtensionArray):
can_hold_na: bool = ...
def __new__(
cls, data, closed=..., dtype=..., copy: bool = ..., verify_integrity: bool = ...
): ...
) -> Self: ...
@classmethod
def from_breaks(
cls,
breaks,
closed: str = "right",
copy: bool = False,
dtype=None,
): ...
) -> Self: ...
@classmethod
def from_arrays(
cls,
Expand All @@ -49,15 +47,15 @@ class IntervalArray(IntervalMixin, ExtensionArray):
closed: str = "right",
copy: bool = False,
dtype=...,
): ...
) -> Self: ...
@classmethod
def from_tuples(
cls,
data,
closed: str = "right",
copy: bool = False,
dtype=None,
): ...
) -> Self: ...
def __array__(
self, dtype: NpDtype | None = None, copy: bool | None = None
) -> np_1darray: ...
Expand Down
5 changes: 3 additions & 2 deletions pandas-stubs/core/arrays/sparse/accessor.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pandas import Series
from pandas.core.accessor import PandasDelegate
from pandas.core.series import Series
from typing_extensions import Self

class BaseAccessor:
def __init__(self, data=...) -> None: ...
Expand All @@ -12,7 +13,7 @@ class SparseAccessor(BaseAccessor, PandasDelegate):

class SparseFrameAccessor(BaseAccessor, PandasDelegate):
@classmethod
def from_spmatrix(cls, data, index=..., columns=...): ...
def from_spmatrix(cls, data, index=..., columns=...) -> Self: ...
def to_dense(self): ...
def to_coo(self): ...
@property
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/arrays/sparse/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SparseArray(ExtensionArray, ExtensionOpsMixin):
copy: bool = ...,
) -> None: ...
@classmethod
def from_spmatrix(cls, data): ...
def from_spmatrix(cls, data) -> Self: ...
def __array__(
self, dtype: NpDtype | None = None, copy: bool | None = None
) -> np_1darray: ...
Expand Down
12 changes: 7 additions & 5 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ from pandas._typing import (
from pandas.io.formats.style import Styler
from pandas.plotting import PlotAccessor

_T_MUTABLE_MAPPING = TypeVar("_T_MUTABLE_MAPPING", bound=MutableMapping, covariant=True)
_T_MUTABLE_MAPPING_co = TypeVar(
"_T_MUTABLE_MAPPING_co", bound=MutableMapping, covariant=True
)

class _iLocIndexerFrame(_iLocIndexer, Generic[_T]):
@overload
Expand Down Expand Up @@ -463,9 +465,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
self,
orient: Literal["records"],
*,
into: _T_MUTABLE_MAPPING | type[_T_MUTABLE_MAPPING],
into: _T_MUTABLE_MAPPING_co | type[_T_MUTABLE_MAPPING_co],
index: Literal[True] = ...,
) -> list[_T_MUTABLE_MAPPING]: ...
) -> list[_T_MUTABLE_MAPPING_co]: ...
@overload
def to_dict(
self,
Expand Down Expand Up @@ -511,9 +513,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
self,
orient: Literal["dict", "list", "series"] = ...,
*,
into: _T_MUTABLE_MAPPING | type[_T_MUTABLE_MAPPING],
into: _T_MUTABLE_MAPPING_co | type[_T_MUTABLE_MAPPING_co],
index: Literal[True] = ...,
) -> _T_MUTABLE_MAPPING: ...
) -> _T_MUTABLE_MAPPING_co: ...
@overload
def to_dict(
self,
Expand Down
23 changes: 14 additions & 9 deletions pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ from pandas._typing import (
C2,
S1,
S2,
S2_CT,
S2_NSDT,
T_COMPLEX,
AnyAll,
Expand All @@ -85,6 +84,7 @@ from pandas._typing import (
MaskType,
NaPosition,
ReindexMethod,
S2_contra,
Scalar,
SequenceNotStr,
SliceType,
Expand Down Expand Up @@ -520,8 +520,8 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
) -> Index[S2]: ...
@overload
def __add__(
self: Index[S2_CT],
other: SupportsRAdd[S2_CT, S2] | Sequence[SupportsRAdd[S2_CT, S2]],
self: Index[S2_contra],
other: SupportsRAdd[S2_contra, S2] | Sequence[SupportsRAdd[S2_contra, S2]],
) -> Index[S2]: ...
@overload
def __add__(
Expand Down Expand Up @@ -573,8 +573,8 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
) -> Index[S2]: ...
@overload
def __radd__(
self: Index[S2_CT],
other: SupportsAdd[S2_CT, S2] | Sequence[SupportsAdd[S2_CT, S2]],
self: Index[S2_contra],
other: SupportsAdd[S2_contra, S2] | Sequence[SupportsAdd[S2_contra, S2]],
) -> Index[S2]: ...
@overload
def __radd__(
Expand Down Expand Up @@ -789,8 +789,11 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
) -> Index[S2]: ...
@overload
def __mul__(
self: Index[S2_CT],
other: SupportsRMul[S2_CT, S2_NSDT] | Sequence[SupportsRMul[S2_CT, S2_NSDT]],
self: Index[S2_contra],
other: (
SupportsRMul[S2_contra, S2_NSDT]
| Sequence[SupportsRMul[S2_contra, S2_NSDT]]
),
) -> Index[S2_NSDT]: ...
@overload
def __mul__(
Expand Down Expand Up @@ -853,8 +856,10 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
) -> Index[S2]: ...
@overload
def __rmul__(
self: Index[S2_CT],
other: SupportsMul[S2_CT, S2_NSDT] | Sequence[SupportsMul[S2_CT, S2_NSDT]],
self: Index[S2_contra],
other: (
SupportsMul[S2_contra, S2_NSDT] | Sequence[SupportsMul[S2_contra, S2_NSDT]]
),
) -> Index[S2_NSDT]: ...
@overload
def __rmul__(
Expand Down
3 changes: 2 additions & 1 deletion pandas-stubs/core/indexes/range.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ from pandas.core.indexes.base import (
Index,
_IndexSubclassBase,
)
from typing_extensions import Self

from pandas._typing import (
HashableT,
Expand All @@ -32,7 +33,7 @@ class RangeIndex(_IndexSubclassBase[int, np.int64]):
name: Hashable = ...,
): ...
@classmethod
def from_range(cls, data, name: Hashable = ..., dtype=...): ...
def from_range(cls, data, name: Hashable = ..., dtype=...) -> Self: ...
def __reduce__(self): ...
@property
def start(self) -> int: ...
Expand Down
62 changes: 38 additions & 24 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ from pandas._libs.tslibs.nattype import NaTType
from pandas._typing import (
S1,
S2,
S2_CT,
S2_CT_NDT,
S2_NSDT,
T_COMPLEX,
AggFuncTypeBase,
Expand Down Expand Up @@ -180,6 +178,8 @@ from pandas._typing import (
ReindexMethod,
Renamer,
ReplaceValue,
S2_contra,
S2_NDT_contra,
Scalar,
ScalarT,
SequenceNotStr,
Expand Down Expand Up @@ -1725,14 +1725,16 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
) -> Series[Timedelta]: ...
@overload
def __add__(
self: Supports_ProtoAdd[S2_CT, S2], other: S2_CT | Sequence[S2_CT]
self: Supports_ProtoAdd[S2_contra, S2], other: S2_contra | Sequence[S2_contra]
) -> Series[S2]: ...
@overload
def __add__(self: Series[S2_CT], other: SupportsRAdd[S2_CT, S2]) -> Series[S2]: ...
def __add__(
self: Series[S2_contra], other: SupportsRAdd[S2_contra, S2]
) -> Series[S2]: ...
# pandas-dev/pandas#62353
@overload
def __add__(
self: Series[S2_CT_NDT], other: Sequence[SupportsRAdd[S2_CT_NDT, S2]]
self: Series[S2_NDT_contra], other: Sequence[SupportsRAdd[S2_NDT_contra, S2]]
) -> Series[S2]: ...
@overload
def __add__(
Expand Down Expand Up @@ -1835,16 +1837,16 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
) -> Series[Timedelta]: ...
@overload
def add(
self: Supports_ProtoAdd[S2_CT, S2],
other: S2_CT | Sequence[S2_CT],
self: Supports_ProtoAdd[S2_contra, S2],
other: S2_contra | Sequence[S2_contra],
level: Level | None = None,
fill_value: float | None = None,
axis: int = 0,
) -> Series[S2]: ...
@overload
def add(
self: Series[S2_CT],
other: SupportsRAdd[S2_CT, S2] | Sequence[SupportsRAdd[S2_CT, S2]],
self: Series[S2_contra],
other: SupportsRAdd[S2_contra, S2] | Sequence[SupportsRAdd[S2_contra, S2]],
level: Level | None = None,
fill_value: float | None = None,
axis: int = 0,
Expand Down Expand Up @@ -1952,14 +1954,16 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
# pyright is unhappy without the above 3 overloads
@overload
def __radd__(
self: Supports_ProtoRAdd[S2_CT, S2], other: S2_CT | Sequence[S2_CT]
self: Supports_ProtoRAdd[S2_contra, S2], other: S2_contra | Sequence[S2_contra]
) -> Series[S2]: ...
@overload
def __radd__(self: Series[S2_CT], other: SupportsAdd[S2_CT, S2]) -> Series[S2]: ...
def __radd__(
self: Series[S2_contra], other: SupportsAdd[S2_contra, S2]
) -> Series[S2]: ...
# pandas-dev/pandas#62353
@overload
def __radd__(
self: Series[S2_CT_NDT], other: Sequence[SupportsAdd[S2_CT_NDT, S2]]
self: Series[S2_NDT_contra], other: Sequence[SupportsAdd[S2_NDT_contra, S2]]
) -> Series[S2]: ...
@overload
def __radd__(
Expand Down Expand Up @@ -2066,16 +2070,16 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
) -> Series[Timedelta]: ...
@overload
def radd(
self: Supports_ProtoRAdd[S2_CT, S2],
other: S2_CT | Sequence[S2_CT],
self: Supports_ProtoRAdd[S2_contra, S2],
other: S2_contra | Sequence[S2_contra],
level: Level | None = None,
fill_value: float | None = None,
axis: int = 0,
) -> Series[S2]: ...
@overload
def radd(
self: Series[S2_CT],
other: SupportsAdd[S2_CT, S2] | Sequence[SupportsAdd[S2_CT, S2]],
self: Series[S2_contra],
other: SupportsAdd[S2_contra, S2] | Sequence[SupportsAdd[S2_contra, S2]],
level: Level | None = None,
fill_value: float | None = None,
axis: int = 0,
Expand Down Expand Up @@ -2532,8 +2536,11 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
) -> Series[S2]: ...
@overload
def __mul__(
self: Series[S2_CT],
other: SupportsRMul[S2_CT, S2_NSDT] | Sequence[SupportsRMul[S2_CT, S2_NSDT]],
self: Series[S2_contra],
other: (
SupportsRMul[S2_contra, S2_NSDT]
| Sequence[SupportsRMul[S2_contra, S2_NSDT]]
),
) -> Series[S2_NSDT]: ...
@overload
def __mul__(
Expand Down Expand Up @@ -2625,8 +2632,11 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
) -> Series[S2]: ...
@overload
def mul(
self: Series[S2_CT],
other: SupportsRMul[S2_CT, S2_NSDT] | Sequence[SupportsRMul[S2_CT, S2_NSDT]],
self: Series[S2_contra],
other: (
SupportsRMul[S2_contra, S2_NSDT]
| Sequence[SupportsRMul[S2_contra, S2_NSDT]]
),
level: Level | None = None,
fill_value: float | None = None,
axis: int = 0,
Expand Down Expand Up @@ -2742,8 +2752,10 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
) -> Series[S2]: ...
@overload
def __rmul__(
self: Series[S2_CT],
other: SupportsMul[S2_CT, S2_NSDT] | Sequence[SupportsMul[S2_CT, S2_NSDT]],
self: Series[S2_contra],
other: (
SupportsMul[S2_contra, S2_NSDT] | Sequence[SupportsMul[S2_contra, S2_NSDT]]
),
) -> Series[S2_NSDT]: ...
@overload
def __rmul__(
Expand Down Expand Up @@ -2835,8 +2847,10 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
) -> Series[S2]: ...
@overload
def rmul(
self: Series[S2_CT],
other: SupportsMul[S2_CT, S2_NSDT] | Sequence[SupportsMul[S2_CT, S2_NSDT]],
self: Series[S2_contra],
other: (
SupportsMul[S2_contra, S2_NSDT] | Sequence[SupportsMul[S2_contra, S2_NSDT]]
),
level: Level | None = None,
fill_value: float | None = None,
axis: int = 0,
Expand Down
Loading