From 6a78d247bd0a24dd2b71598398353e5a68210487 Mon Sep 17 00:00:00 2001 From: caneff Date: Mon, 4 Sep 2023 07:55:28 -0400 Subject: [PATCH 1/2] Add inplace overloads for interpolate This will help our type checker work better and is a plain improvement to the type hints. --- pandas/core/generic.py | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index b9407ebe6624a..b3e7ce81f544c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -7938,6 +7938,51 @@ def replace( else: return result.__finalize__(self, method="replace") + @overload + def interpolate( + self, + method: InterpolateOptions = ..., + *, + axis: Axis = ..., + limit: int | None = ..., + inplace: Literal[False] = ..., + limit_direction: Literal["forward", "backward", "both"] | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., + downcast: Literal["infer"] | None | lib.NoDefault = ..., + **kwargs, + ) -> Self: + ... + + @overload + def interpolate( + self, + method: InterpolateOptions = ..., + *, + axis: Axis = ..., + limit: int | None = ..., + inplace: Literal[True], + limit_direction: Literal["forward", "backward", "both"] | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., + downcast: Literal["infer"] | None | lib.NoDefault = ..., + **kwargs, + ) -> None: + ... + + @overload + def interpolate( + self, + method: InterpolateOptions = ..., + *, + axis: Axis = ..., + limit: int | None = ..., + inplace: bool_t = ..., + limit_direction: Literal["forward", "backward", "both"] | None = ..., + limit_area: Literal["inside", "outside"] | None = ..., + downcast: Literal["infer"] | None | lib.NoDefault = ..., + **kwargs, + ) -> Self | None: + ... + @final def interpolate( self, From 44d181b7ee89eb6de208e9129e3acfd0c6403e18 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:26:41 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pandas/core/generic.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index b3e7ce81f544c..671cfc11df597 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -7952,7 +7952,7 @@ def interpolate( **kwargs, ) -> Self: ... - + @overload def interpolate( self, @@ -7967,7 +7967,7 @@ def interpolate( **kwargs, ) -> None: ... - + @overload def interpolate( self, @@ -7981,8 +7981,8 @@ def interpolate( downcast: Literal["infer"] | None | lib.NoDefault = ..., **kwargs, ) -> Self | None: - ... - + ... + @final def interpolate( self,