Skip to content

TYP: pandas/core/frame.py (easy: Axis/Level) #38441

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

Merged
merged 4 commits into from
Dec 13, 2020

Conversation

arw2019
Copy link
Member

@arw2019 arw2019 commented Dec 13, 2020

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Splitting this away from #38416

@arw2019 arw2019 mentioned this pull request Dec 13, 2020
5 tasks
@@ -5943,7 +5945,7 @@ def swaplevel(self, i=-2, j=-1, axis=0) -> DataFrame:
result.columns = result.columns.swaplevel(i, j)
return result

def reorder_levels(self, order, axis=0) -> DataFrame:
def reorder_levels(self, order: Sequence[Axis], axis: Axis = 0) -> DataFrame:
Copy link
Member Author

Choose a reason for hiding this comment

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

This has to be Sequence not List because with List mypy complains

pandas/core/generic.py:8689: error: Argument 1 to "reorder_levels" of "DataFrame" has incompatible type "List[int]"; expected "List[Union[str, int]]"  [arg-type]
pandas/core/generic.py:8689: note: "List" is invariant -- see http://mypy.readthedocs.io/en/latest/common_issues.html#variance
pandas/core/generic.py:8689: note: Consider using "Sequence" instead, which is covariant
pandas/core/generic.py:8691: error: Argument 1 to "reorder_levels" of "DataFrame" has incompatible type "List[int]"; expected "List[Union[str, int]]"  [arg-type]
pandas/core/generic.py:8691: note: "List" is invariant -- see http://mypy.readthedocs.io/en/latest/common_issues.html#variance
pandas/core/generic.py:8691: note: Consider using "Sequence" instead, which is covariant

@jreback
Copy link
Contributor

jreback commented Dec 13, 2020

looks fine. merge master and ping on green.

@jreback jreback added the Typing type annotations, mypy/pyright type checking label Dec 13, 2020
@jreback jreback added this to the 1.3 milestone Dec 13, 2020
@arw2019
Copy link
Member Author

arw2019 commented Dec 13, 2020

Rebased + green

@jreback jreback merged commit 92b73d8 into pandas-dev:master Dec 13, 2020
@jreback
Copy link
Contributor

jreback commented Dec 13, 2020

thanks

luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
* typing (Axis/Level)

* review comment

* replace List[Axis]->Sequence[Axis] in reorder_levels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants