-
-
Notifications
You must be signed in to change notification settings - Fork 141
GH1189/GH1181 Timestamp subtraction and index shift #1191
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
Conversation
pandas-stubs/core/indexes/base.pyi
Outdated
@@ -393,7 +393,7 @@ class Index(IndexOpsMixin[S1]): | |||
def asof_locs(self, where, mask): ... | |||
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: ... |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
pandas-stubs/core/indexes/base.pyi
Outdated
@@ -393,7 +393,7 @@ class Index(IndexOpsMixin[S1]): | |||
def asof_locs(self, where, mask): ... | |||
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: ... |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @loicdiridollou
assert_type()
to assert the type of any return value