Skip to content

TYP: NDFrame sort_values signature #37866

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

Closed
ivanovmg opened this issue Nov 15, 2020 · 1 comment
Closed

TYP: NDFrame sort_values signature #37866

ivanovmg opened this issue Nov 15, 2020 · 1 comment
Labels
API - Consistency Internal Consistency of API/Behavior Duplicate Report Duplicate issue or pull request Needs Triage Issue that has not been reviewed by a pandas team member Typing type annotations, mypy/pyright type checking

Comments

@ivanovmg
Copy link
Member

ivanovmg commented Nov 15, 2020

NDFrame sort_values and inheritance

The question is related to method sort_values of NDFrame, DataFrame and Series.
When trying to close one issue in (#37715) below

pandas/core/frame.py:5361: def sort_values( # type: ignore[override]

I found out that the function signatures for NDFrame and DataFrame do not match because of the argument by.
That was the cause of the mypy error.
For Series.sort_values it is reasonable not to have by, but for DataFrame it is mandatory.
So, the function signatures for Series and DataFrame must be different and should not share the common interface.

Presumably, currently the method NDFrame.sort_values only stores the docstring for DataFrame.sort_values.
It is reasonable to move the docstring to DataFrame.sort_values and completely remove abstract method NDFrame.sort_values?
This will solve the problem with incorrect overriding.

@ivanovmg ivanovmg added Needs Triage Issue that has not been reviewed by a pandas team member Usage Question Typing type annotations, mypy/pyright type checking API - Consistency Internal Consistency of API/Behavior and removed Usage Question labels Nov 15, 2020
@mzeitlin11
Copy link
Member

Closing in favor of #30451

@mzeitlin11 mzeitlin11 added the Duplicate Report Duplicate issue or pull request label Jan 10, 2021
@mzeitlin11 mzeitlin11 added this to the No action milestone Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Duplicate Report Duplicate issue or pull request Needs Triage Issue that has not been reviewed by a pandas team member Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

No branches or pull requests

2 participants