diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cc0e9aaa0..1786d3276 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: hooks: - id: isort - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.278 + rev: v0.0.282 hooks: - id: ruff args: [ diff --git a/pandas-stubs/_typing.pyi b/pandas-stubs/_typing.pyi index 27548758f..4306aede0 100644 --- a/pandas-stubs/_typing.pyi +++ b/pandas-stubs/_typing.pyi @@ -664,6 +664,26 @@ StataDateFormat: TypeAlias = Literal[ ] FillnaOptions: TypeAlias = Literal["backfill", "bfill", "ffill", "pad"] +InterpolateOptions: TypeAlias = Literal[ + "linear", + "time", + "index", + "pad", + "nearest", + "zero", + "slinear", + "quadratic", + "cubic", + "barycentric", + "polynomial", + "krogh", + "piecewise_polynomial", + "spline", + "pchip", + "akima", + "cubicspline", + "from_derivatives", +] ReplaceMethod: TypeAlias = Literal["pad", "ffill", "bfill"] SortKind: TypeAlias = Literal["quicksort", "mergesort", "heapsort", "stable"] NaPosition: TypeAlias = Literal["first", "last"] diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index f9c195b18..a8f46facb 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -86,6 +86,7 @@ from pandas._typing import ( IndexingInt, IndexLabel, IndexType, + InterpolateOptions, IntervalClosedType, IntervalT, JoinHow, @@ -1704,7 +1705,7 @@ class DataFrame(NDFrame, OpsMixin): @overload def interpolate( self, - method: _str = ..., + method: InterpolateOptions = ..., *, axis: Axis = ..., limit: int | None = ..., @@ -1717,7 +1718,7 @@ class DataFrame(NDFrame, OpsMixin): @overload def interpolate( self, - method: _str = ..., + method: InterpolateOptions = ..., *, axis: Axis = ..., limit: int | None = ..., @@ -1730,7 +1731,7 @@ class DataFrame(NDFrame, OpsMixin): @overload def interpolate( self, - method: _str = ..., + method: InterpolateOptions = ..., *, axis: Axis = ..., limit: int | None = ..., diff --git a/pandas-stubs/core/resample.pyi b/pandas-stubs/core/resample.pyi index 23de00bf3..a21b7dfcf 100644 --- a/pandas-stubs/core/resample.pyi +++ b/pandas-stubs/core/resample.pyi @@ -22,6 +22,7 @@ from typing_extensions import TypeAlias from pandas._typing import ( Axis, + InterpolateOptions, NDFrameT, Scalar, npt, @@ -50,28 +51,6 @@ _SeriesGroupByFuncArgs: TypeAlias = ( _SeriesGroupByFuncTypes | Mapping[Hashable, _SeriesGroupByFunc | str] ) -_Interpolation: TypeAlias = Literal[ - "linear", - "time", - "index", - "pad", - "nearest", - "zero", - "slinear", - "quadratic", - "cubic", - "spline", - "barycentric", - "polynomial", - "krogh", - "piecewise_polynomial", - "spline", - "pchip", - "akima", - "cubicspline", - "from_derivatives", -] - class Resampler(BaseGroupBy, Generic[NDFrameT]): def __getattr__(self, attr: str) -> SeriesGroupBy: ... def __iter__(self) -> Generator[tuple[Hashable, NDFrameT], None, None]: ... @@ -147,7 +126,7 @@ class Resampler(BaseGroupBy, Generic[NDFrameT]): @overload def interpolate( self, - method: _Interpolation = ..., + method: InterpolateOptions = ..., *, axis: Axis = ..., limit: int | None = ..., @@ -160,7 +139,7 @@ class Resampler(BaseGroupBy, Generic[NDFrameT]): @overload def interpolate( self, - method: _Interpolation = ..., + method: InterpolateOptions = ..., *, axis: Axis = ..., limit: int | None = ..., diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index c05e74237..813491e0f 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -118,6 +118,7 @@ from pandas._typing import ( IgnoreRaise, IndexingInt, IntDtypeArg, + InterpolateOptions, IntervalClosedType, IntervalT, JoinHow, @@ -1273,27 +1274,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): ) -> Series[S1] | None: ... def interpolate( self, - method: _str - | Literal[ - "linear", - "time", - "index", - "values", - "pad", - "nearest", - "slinear", - "quadratic", - "cubic", - "spline", - "barycentric", - "polynomial", - "krogh", - "pecewise_polynomial", - "spline", - "pchip", - "akima", - "from_derivatives", - ] = ..., + method: InterpolateOptions = ..., *, axis: AxisIndex | None = ..., limit: int | None = ..., diff --git a/tests/test_scalars.py b/tests/test_scalars.py index 958a03b61..8c946839d 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -1745,7 +1745,7 @@ def test_period_add_subtract() -> None: as_dt_td = dt.timedelta(days=1) as_np_td = np.timedelta64(1, "D") as_np_i64 = np.int64(1) - as_int = int(1) + as_int: int = 1 as_period_index = pd.period_range("2012-1-1", periods=10, freq="D") check(assert_type(as_period_index, pd.PeriodIndex), pd.PeriodIndex) as_period = pd.Period("2012-1-1", freq="D")