Skip to content

Conversation

loicdiridollou
Copy link
Member

def sort_values(self, return_indexer: bool = ..., ascending: bool = ...): ...
def sort(self, *args, **kwargs) -> None: ...
def shift(self, periods: int = ..., freq=...) -> None: ...
def shift(self, periods: int = ..., freq=...) -> Self: ...
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small question here, pd.Index.shift is technically not implemented so wondering if it should be NoReturn here and Self for pd.DatetimeIndex, pd.TimedeltaIndex and pd.PeriodIndex or if this is fine as is (technically it would fail at runtime anyway so the typing would not help much to spot the bug).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should take shift() out of here and only include it in the stubs for those 3 types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! Thanks for the direction

def sort_values(self, return_indexer: bool = ..., ascending: bool = ...): ...
def sort(self, *args, **kwargs) -> None: ...
def shift(self, periods: int = ..., freq=...) -> None: ...
def shift(self, periods: int = ..., freq=...) -> Self: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should take shift() out of here and only include it in the stubs for those 3 types.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dr-Irv Dr-Irv merged commit 351810b into pandas-dev:main Apr 19, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pd.Index().shift() claims to return None

2 participants