Skip to content

TYP/CLN: remove no-longer-needed overrides #52007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 17, 2023
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
4 changes: 4 additions & 0 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.Series.is_monotonic_increasing \
pandas.Series.is_monotonic_decreasing \
pandas.Series.backfill \
pandas.Series.bfill \
pandas.Series.ffill \
pandas.Series.pad \
pandas.Series.argsort \
pandas.Series.reorder_levels \
Expand Down Expand Up @@ -541,6 +543,8 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.DataFrame.iterrows \
pandas.DataFrame.pipe \
pandas.DataFrame.backfill \
pandas.DataFrame.bfill \
pandas.DataFrame.ffill \
pandas.DataFrame.pad \
pandas.DataFrame.swapaxes \
pandas.DataFrame.first_valid_index \
Expand Down
242 changes: 8 additions & 234 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6792,14 +6792,13 @@ def sort_values(
elif len(by):
# len(by) == 1

by = by[0]
k = self._get_label_or_level_values(by, axis=axis)
k = self._get_label_or_level_values(by[0], axis=axis)

# need to rewrap column in Series to apply key function
if key is not None:
# error: Incompatible types in assignment (expression has type
# "Series", variable has type "ndarray")
k = Series(k, name=by) # type: ignore[assignment]
k = Series(k, name=by[0]) # type: ignore[assignment]

if isinstance(ascending, (tuple, list)):
ascending = ascending[0]
Expand Down Expand Up @@ -11386,8 +11385,7 @@ def quantile(
keys = [data._get_label_or_level_values(x) for x in by]
indexer = lexsort_indexer(keys)
else:
by = by[0]
k = data._get_label_or_level_values(by) # type: ignore[arg-type]
k = data._get_label_or_level_values(by[0])
indexer = nargsort(k)

res = data._mgr.take(indexer[q_idx], verify=False)
Expand Down Expand Up @@ -11667,10 +11665,12 @@ def isin(self, values: Series | DataFrame | Sequence | Mapping) -> DataFrame:
# error: Argument 2 to "isin" has incompatible type "Union[Sequence[Any],
# Mapping[Any, Any]]"; expected "Union[Union[ExtensionArray,
# ndarray[Any, Any]], Index, Series]"
res_values = algorithms.isin(
self.values.ravel(),
values, # type: ignore[arg-type]
)
result = self._constructor(
algorithms.isin(
self.values.ravel(), values # type: ignore[arg-type]
).reshape(self.shape),
res_values.reshape(self.shape),
self.index,
self.columns,
)
Expand Down Expand Up @@ -11795,232 +11795,6 @@ def values(self) -> np.ndarray:
"""
return self._mgr.as_array()

@overload
def ffill(
self,
*,
axis: None | Axis = ...,
inplace: Literal[False] = ...,
limit: None | int = ...,
downcast: dict | None = ...,
) -> DataFrame:
...

@overload
def ffill(
self,
*,
axis: None | Axis = ...,
inplace: Literal[True],
limit: None | int = ...,
downcast: dict | None = ...,
) -> None:
...

@overload
def ffill(
self,
*,
axis: None | Axis = ...,
inplace: bool = ...,
limit: None | int = ...,
downcast: dict | None = ...,
) -> DataFrame | None:
...

def ffill(
self,
*,
axis: None | Axis = None,
inplace: bool = False,
limit: None | int = None,
downcast: dict | None = None,
) -> DataFrame | None:
return super().ffill(axis=axis, inplace=inplace, limit=limit, downcast=downcast)

@overload
def bfill(
self,
*,
axis: None | Axis = ...,
inplace: Literal[False] = ...,
limit: None | int = ...,
downcast=...,
) -> DataFrame:
...

@overload
def bfill(
self,
*,
axis: None | Axis = ...,
inplace: Literal[True],
limit: None | int = ...,
downcast=...,
) -> None:
...

@overload
def bfill(
self,
*,
axis: None | Axis = ...,
inplace: bool = ...,
limit: None | int = ...,
downcast=...,
) -> DataFrame | None:
...

def bfill(
self,
*,
axis: None | Axis = None,
inplace: bool = False,
limit: None | int = None,
downcast=None,
) -> DataFrame | None:
return super().bfill(axis=axis, inplace=inplace, limit=limit, downcast=downcast)

def clip(
self: DataFrame,
lower: float | None = None,
upper: float | None = None,
*,
axis: Axis | None = None,
inplace: bool = False,
**kwargs,
) -> DataFrame | None:
return super().clip(lower, upper, axis=axis, inplace=inplace, **kwargs)

def interpolate(
self: DataFrame,
method: str = "linear",
*,
axis: Axis = 0,
limit: int | None = None,
inplace: bool = False,
limit_direction: str | None = None,
limit_area: str | None = None,
downcast: str | None = None,
**kwargs,
) -> DataFrame | None:
return super().interpolate(
method=method,
axis=axis,
limit=limit,
inplace=inplace,
limit_direction=limit_direction,
limit_area=limit_area,
downcast=downcast,
**kwargs,
)

@overload
def where(
self,
cond,
other=...,
*,
inplace: Literal[False] = ...,
axis: Axis | None = ...,
level: Level = ...,
) -> DataFrame:
...

@overload
def where(
self,
cond,
other=...,
*,
inplace: Literal[True],
axis: Axis | None = ...,
level: Level = ...,
) -> None:
...

@overload
def where(
self,
cond,
other=...,
*,
inplace: bool = ...,
axis: Axis | None = ...,
level: Level = ...,
) -> DataFrame | None:
...

def where(
self,
cond,
other=lib.no_default,
*,
inplace: bool = False,
axis: Axis | None = None,
level: Level = None,
) -> DataFrame | None:
return super().where(
cond,
other,
inplace=inplace,
axis=axis,
level=level,
)

@overload
def mask(
self,
cond,
other=...,
*,
inplace: Literal[False] = ...,
axis: Axis | None = ...,
level: Level = ...,
) -> DataFrame:
...

@overload
def mask(
self,
cond,
other=...,
*,
inplace: Literal[True],
axis: Axis | None = ...,
level: Level = ...,
) -> None:
...

@overload
def mask(
self,
cond,
other=...,
*,
inplace: bool = ...,
axis: Axis | None = ...,
level: Level = ...,
) -> DataFrame | None:
...

def mask(
self,
cond,
other=lib.no_default,
*,
inplace: bool = False,
axis: Axis | None = None,
level: Level = None,
) -> DataFrame | None:
return super().mask(
cond,
other,
inplace=inplace,
axis=axis,
level=level,
)


DataFrame._add_numeric_operations()

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12021,7 +12021,7 @@ def ewm(
# Arithmetic Methods

@final
def _inplace_method(self, other, op):
def _inplace_method(self, other, op) -> Self:
"""
Wrap arithmetic method to operate inplace.
"""
Expand Down
Loading