Skip to content
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

Fix mypy errors for pandas\tests\series\test_operators.py #29826

Conversation

SaturnFromTitan
Copy link
Contributor

@SaturnFromTitan SaturnFromTitan commented Nov 24, 2019

part of #28926

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

The errors were:

pandas/tests/series/test_operators.py:824: error: "Type[Series]" has no attribute "div"
pandas/tests/series/test_operators.py:824: error: "Type[Series]" has no attribute "rdiv"

The problem is that these methods are only added at RunTime, so mypy can't see them. I'm not sure if my solution is the best way to silence these errors though.

@SaturnFromTitan SaturnFromTitan force-pushed the mypy-pandas-tests-series-test_operators branch 2 times, most recently from 44806e1 to 5922a8c Compare November 24, 2019 22:25
@simonjayhawkins
Copy link
Member

The problem is that these methods are only added at RunTime, so mypy can't see them. I'm not sure if my solution is the best way to silence these errors though.

they are added in add_flex_arithmetic_methods which is passed the class as a parameter. They could therefore be specific to a class and so adding them directly in Series (and adding similar in DataFrame separately) seems reasonable to me.

@simonjayhawkins simonjayhawkins added this to the 1.0 milestone Nov 25, 2019
@simonjayhawkins simonjayhawkins added Testing pandas testing functions or related to the test suite Typing type annotations, mypy/pyright type checking labels Nov 25, 2019
@SaturnFromTitan SaturnFromTitan force-pushed the mypy-pandas-tests-series-test_operators branch from 5d144f5 to 8fe766e Compare November 25, 2019 23:19
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

@SaturnFromTitan lgtm pending ci fixes.

@SaturnFromTitan SaturnFromTitan force-pushed the mypy-pandas-tests-series-test_operators branch from 8fe766e to 8392174 Compare November 26, 2019 11:28
@SaturnFromTitan SaturnFromTitan force-pushed the mypy-pandas-tests-series-test_operators branch from 8392174 to b2ee5ed Compare November 27, 2019 10:23
@SaturnFromTitan
Copy link
Contributor Author

@simonjayhawkins the build is green again

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

@WillAyd WillAyd merged commit 05bb7be into pandas-dev:master Nov 27, 2019
@WillAyd
Copy link
Member

WillAyd commented Nov 27, 2019

Thanks @SaturnFromTitan

keechongtan added a commit to keechongtan/pandas that referenced this pull request Nov 29, 2019
…ndexing-1row-df

* upstream/master: (32 commits)
  DEPR: Series.cat.categorical (pandas-dev#29914)
  DEPR: infer_dtype default for skipna is now True (pandas-dev#29876)
  Fix broken asv (pandas-dev#29906)
  DEPR: Remove weekday_name (pandas-dev#29831)
  Fix mypy errors for pandas\tests\series\test_operators.py (pandas-dev#29826)
  CI: Setting path only once in GitHub Actions (pandas-dev#29867)
  DEPR: passing td64 data to DTA or dt64 data to TDA (pandas-dev#29794)
  CLN: remove unsupported sparse code from io.pytables (pandas-dev#29863)
  x.__class__ TO type(x) (pandas-dev#29889)
  DEPR: ftype, ftypes (pandas-dev#29895)
  REF: use named funcs instead of lambdas (pandas-dev#29841)
  Correct type inference for UInt64Index during access (pandas-dev#29420)
  CLN: follow-up to 29725 (pandas-dev#29890)
  CLN: trim unnecessary code in indexing tests (pandas-dev#29845)
  TST added test for groupby agg on mulitlevel column (pandas-dev#29772) (pandas-dev#29866)
  mypy fix (pandas-dev#29891)
  Typing annotations (pandas-dev#29850)
  Fix mypy error in pandas/tests.indexes.test_base.py (pandas-dev#29188)
  CLN: remove never-used kwargs, make kwargs explicit (pandas-dev#29873)
  TYP: Added typing to __eq__ functions (pandas-dev#29818)
  ...
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants