Skip to content

Commit

Permalink
TYP: Use Self instead of class-bound TypeVar (generic.py/frame.py/ser…
Browse files Browse the repository at this point in the history
…ies.py) (#51493)

* TYP: Use Self for type checking

* type frame.py & series.py

* TYP: change Index to Self
  • Loading branch information
topper-123 committed Mar 15, 2023
1 parent 93b5135 commit f26031e
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 224 deletions.
7 changes: 4 additions & 3 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
ReadBuffer,
Renamer,
Scalar,
Self,
SortKind,
StorageOptions,
Suffixes,
Expand Down Expand Up @@ -2495,7 +2496,7 @@ def _from_arrays(
index,
dtype: Dtype | None = None,
verify_integrity: bool = True,
) -> DataFrame:
) -> Self:
"""
Create DataFrame from a list of arrays corresponding to the columns.
Expand Down Expand Up @@ -4597,7 +4598,7 @@ def eval(self, expr: str, *, inplace: bool = False, **kwargs) -> Any | None:

return _eval(expr, inplace=inplace, **kwargs)

def select_dtypes(self, include=None, exclude=None) -> DataFrame:
def select_dtypes(self, include=None, exclude=None) -> Self:
"""
Return a subset of the DataFrame's columns based on the column dtypes.
Expand Down Expand Up @@ -5015,7 +5016,7 @@ def align(
limit: int | None = None,
fill_axis: Axis = 0,
broadcast_axis: Axis | None = None,
) -> tuple[DataFrame, NDFrameT]:
) -> tuple[Self, NDFrameT]:
return super().align(
other,
join=join,
Expand Down

0 comments on commit f26031e

Please sign in to comment.