-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
TYP: sort_index #46300
TYP: sort_index #46300
Conversation
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.
make the types consistent (bool
vs. bool_t
) between generic.py
and series.py
, frame.py
pandas/core/frame.py
Outdated
@@ -6446,7 +6449,7 @@ def sort_index( | |||
|
|||
@overload | |||
def sort_index( | |||
self, | |||
self: DataFrameT, |
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.
as far as I remember, pyright doesn't like self annotations that are broader than the class itself (cannot use NDFrameT).
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.
Questions about the ascending
argument and typing self
on all overloads.
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 @twoertwein generally lgtm.
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 @twoertwein
The requested changes were to keep the scope of this PR narrow and for consistency with the existing code. (and not necessarily the correct thing to do)
#32638 could potentially discuss changes on how the _constructor mechanism works. We maybe need a more limited discussion from a typing perspective considering a trade-off for false positives and more refined return types for the public api.
Also a similar discussion is maybe needed considering a trade-off for false positives and catching more errors using Literal for the Axis parameter in the public api.
I'll leave it to someone else to champion these issues as I try to backseat on the public api typing issues as it generally needs a different approach to the internal typing of the codebase and is therefore difficult to not give out mixed messages on typing policy.
can you merge master |
Conflicts: doc/source/whatsnew/v1.4.2.rst pandas/_typing.py
green, except for mypy error also present on main |
thanks @twoertwein (and others!) |
Tested the overloads with mypy and pyright: