-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Replace FrameOrSeriesUnion annotation by DataFrame | Series #41955
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
CLN: Replace FrameOrSeriesUnion annotation by DataFrame | Series #41955
Conversation
Swanand01
commented
Jun 11, 2021
•
edited by simonjayhawkins
Loading
edited by simonjayhawkins
- closes STYLE, TYP frame-or-series-union check no longer relevant #40876
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
@github-actions pre-commit |
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.
pandas/plotting/_matplotlib/timeseries.py:212:35: F821 undefined name 'DataFrame'
pandas/io/formats/info.py:112:23: F821 undefined name 'Series'
pandas/io/formats/info.py:415:35: F821 undefined name 'Series'
pandas/core/window/expanding.py:590:16: F821 undefined name 'DataFrame'
pandas/core/window/expanding.py:590:28: F821 undefined name 'Series'
pandas/core/window/expanding.py:655:16: F821 undefined name 'DataFrame'
pandas/core/window/expanding.py:655:28: F821 undefined name 'Series'
pandas/core/strings/accessor.py:2314:10: F821 undefined name 'DataFrame'
pandas/core/strings/accessor.py:2314:22: F821 undefined name 'Series'
pandas/plotting/_matplotlib/tools.py:56:15: F821 undefined name 'DataFrame'
pandas/plotting/_matplotlib/tools.py:56:27: F821 undefined name 'Series'
pandas/core/window/ewm.py:514:16: F821 undefined name 'DataFrame'
pandas/core/window/ewm.py:514:28: F821 undefined name 'Series'
pandas/core/window/ewm.py:581:16: F821 undefined name 'DataFrame'
pandas/core/window/ewm.py:581:28: F821 undefined name 'Series'
pandas/core/util/hashing.py:77:18: F821 undefined name 'DataFrame'
For such files you should import Series
and DataFrame
. If you need to avoid a circular import, you can do like they do here:
pandas/pandas/compat/pickle_compat.py
Lines 26 to 30 in 8f70ed5
if TYPE_CHECKING: | |
from pandas import ( | |
DataFrame, | |
Series, | |
) |
Hi @MarcoGorelli, would you mind taking a look at my last commit, I don't really know why the particular test is failing. Thank you. |
see #41955 (review) for the mypy failures. There is also a pre-commit failure. see https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit |
I fixed all the mypy errors from the prev. commit in this commit. Should I run @github-actions pre-commit like it says in the documentation? |
They're still failing, if you click "details" you'll see the failures:
This won't fix the |
Hi, I can't seem to understand these pre-commit errors. Are they formatting related? |
Hey @Swanand01 - yeah, see here for how to run them Seems like this is on the right track anyway! |
Hi @MarcoGorelli , all checks pass now. Thank you. |
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.
Looks good to me, thanks for having stuck with this!
Hi, how will this PR be merged? Do I have to close this PR now? |
no do not close. other reviewers could either request changes, add their approval or merge this. |
Okay thanks. |
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 @Swanand01 lgtm. just a couple of suggestions.
@@ -1362,7 +1361,7 @@ def dot(self, other: Series) -> Series: | |||
def dot(self, other: DataFrame | Index | ArrayLike) -> DataFrame: | |||
... | |||
|
|||
def dot(self, other: AnyArrayLike | FrameOrSeriesUnion) -> FrameOrSeriesUnion: | |||
def dot(self, other: AnyArrayLike | DataFrame | Series) -> DataFrame | Series: |
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.
A Series is also AnyArrayLike
def dot(self, other: AnyArrayLike | DataFrame | Series) -> DataFrame | Series: | |
def dot(self, other: AnyArrayLike | DataFrame) -> DataFrame | Series: |
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.
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.
ok. we can merge this and let the check fix this
@@ -1478,13 +1477,13 @@ def __matmul__(self, other: Series) -> Series: | |||
|
|||
@overload | |||
def __matmul__( | |||
self, other: AnyArrayLike | FrameOrSeriesUnion | |||
) -> FrameOrSeriesUnion: | |||
self, other: AnyArrayLike | DataFrame | Series |
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.
same (and already included in previous overload anyway)
... | ||
|
||
def __matmul__( | ||
self, other: AnyArrayLike | FrameOrSeriesUnion | ||
) -> FrameOrSeriesUnion: | ||
self, other: AnyArrayLike | DataFrame | Series |
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.
same
@@ -1362,7 +1361,7 @@ def dot(self, other: Series) -> Series: | |||
def dot(self, other: DataFrame | Index | ArrayLike) -> DataFrame: | |||
... | |||
|
|||
def dot(self, other: AnyArrayLike | FrameOrSeriesUnion) -> FrameOrSeriesUnion: | |||
def dot(self, other: AnyArrayLike | DataFrame | Series) -> DataFrame | Series: |
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.
ok. we can merge this and let the check fix this
Thanks @Swanand01 |
@simonjayhawkins I thought we discussed in our monthly dev meeting to not do this change because you lose the typeahead feature in editors. I.e., you can do typeahead for |
@Dr-Irv my understanding was that that conversation in the dev meeting was spurred from the fact that it looked like this PR had gone stale and it was marked for 1.3. In light of that, and of the typeahead issue you brought up, it didn't seem worth pushing it though Once activity resumed, though, it seemed fine to stick with it. Perhaps I should've pinged you to check, sorry about that No objection to reverting (or re-discussing in the next dev meeting) if you wish, but I do think this is fine to keep. An unexpected benefit is that it's helped make it clear that there are cases when it's redundant to have |
agreed. and with #42367 removing the redundant typevars, things become clearer still. |