Skip to content

DataFrame.reorders order parameter is incorrectly typed #560

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
aberres opened this issue Mar 2, 2023 · 1 comment
Closed

DataFrame.reorders order parameter is incorrectly typed #560

aberres opened this issue Mar 2, 2023 · 1 comment

Comments

@aberres
Copy link

aberres commented Mar 2, 2023

The last release introduced proper typing of Axis.

This clashes with improper typing of

DataFrame.reorder_levels(self, order: Sequence[Axis], axis: Axis = 0)

order should likely be typed as Sequence[Hashable].

Snippet

import pandas as pd

df: pd.DataFrame = pd.DataFrame([0])

l = ['a', 'b']

df.reorder_levels(l)

Mypy output

axis.py:7: error: Argument 1 to "reorder_levels" of "DataFrame" has incompatible type "List[str]"; expected "Sequence[Union[Literal[0, 1], Literal['index', 'columns', 'rows']]]"  [arg-type]
    df.reorder_levels(l)
@aberres
Copy link
Author

aberres commented Mar 28, 2023

I had a look, and this is no issue after all. pandas-stubs already types as def reorder_levels(self, order: list, axis: Axis = ...)

What happened? From back in the days I had my own stubs for DataFrame still around - and these had the incorrect typing.

@aberres aberres closed this as completed Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants