-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: tests/extension/json/test_json.py typefix #28994
Conversation
The error is due to the fact that the builtins.staticmethod type defined in extension.base.base.BaseExtensionTests does not match the function type in extension.json.test_json.BaseJSON. I don't see a possibility for a type hint fix without changing the structure of the code. One way would be to replace the call of staticmethod by function definitions that call the corresponding methods. Here I propose an easier suppression of the error using type: Any. What do you think?
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.
@lukasbk can you rebase |
pandas/tests/extension/base/base.py
Outdated
@@ -2,8 +2,18 @@ | |||
|
|||
|
|||
class BaseExtensionTests: | |||
@staticmethod | |||
def assert_equal(left, right, **kwargs): | |||
return tm.assert_equal(left, right, **kwargs) |
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.
don't need the return
pandas/tests/extension/base/base.py
Outdated
assert_extension_array_equal = staticmethod(tm.assert_extension_array_equal) | ||
@staticmethod | ||
def assert_series_equal(left, right, **kwargs): | ||
return tm.assert_series_equal(left, right, **kwargs) |
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
pandas/tests/extension/base/base.py
Outdated
|
||
@staticmethod | ||
def assert_frame_equal(left, right, **kwargs): | ||
return tm.assert_frame_equal(left, right, **kwargs) |
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
pandas/tests/extension/base/base.py
Outdated
|
||
@staticmethod | ||
def assert_extension_array_equal(left, right, **kwargs): | ||
return tm.assert_extension_array_equal(left, right, **kwargs) |
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
@@ -2,8 +2,18 @@ | |||
|
|||
|
|||
class BaseExtensionTests: | |||
@staticmethod |
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.
Can you get rid of these methods altogether and just import / use as function within tests?
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.
I don't think so, since some tests need to override these
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.
Hmm OK - so was this change required? Looks like using tm.assert_*
in the tests now?
@lukasbk looks like a merge conflict; can you fix up and address comments? |
pandas/tests/extension/base/base.py
Outdated
@@ -2,8 +2,18 @@ | |||
|
|||
|
|||
class BaseExtensionTests: | |||
@staticmethod | |||
def assert_equal(left, right, **kwargs): |
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.
AFAICT it's only assert_series_equal
and assert_frame_equal
that currently need to be overridden in specific extension array tests, so assert_equal
and assert_extension_array_equal
don't need to be changed at this time.
assert_equal and assert_extension_array_equal were not needed to be overwritten. Instead they can be directly accessed from testing.
looks ok to me. I am bit concerned that we are now changing back to using |
can you rebase |
@lukasbk can you fix up the merge conflict? I think we can get this in if so |
@lukasbk the CI didn't pass, and this is conflicting again. Do you mind merging master again, making sure the CI passes, and pinging us to get this merged quickly after that please? Thanks! |
@lukasbk can you fix up merge conflict? I think this was close |
closing as stale. cc @SaturnFromTitan |
The error is due to the fact that the builtins.staticmethod type defined in extension.base.base.BaseExtensionTests does not match the function type in extension.json.test_json.BaseJSON. I don't see a possibility for a proper type hint fix without changing the structure of the code. One way would be to replace the call of staticmethod by function definitions that call the corresponding methods.
Here I propose an easier suppression of the error using type: Any.
What do you think?
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff