-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
CLN: some simple code cleanup #47438
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
Conversation
@@ -640,7 +640,7 @@ def test_map_abc_mapping_with_missing(non_dict_mapping_subclass): | |||
# https://github.com/pandas-dev/pandas/issues/29733 | |||
# Check collections.abc.Mapping support as mapper for Series.map | |||
class NonDictMappingWithMissing(non_dict_mapping_subclass): | |||
def __missing__(key): |
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.
this looks like it should fail in the status quo. does this change fix anything?
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.
Sorry for the delay, @jbrockmendel ! In this case, for example, it doesn't fail because missing is not directly called. Essentially these changes don't fix anything but code readability and correctness.
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 @hydratedguy, really nice clean up.
Except the return
, I think all the other methods should be failing if used. I checked __len__
and __getitem__
and they raised, if used as expected:
>>> class Foo:
... def __len__(self, n):
... return 1
...
>>> foo = Foo()
>>> len(foo)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __len__() missing 1 required positional argument: 'n'
>>> class A:
... def __getitem__(self):
... return 1
...
>>> a = A()
>>> a['b']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __getitem__() takes 1 positional argument but 2 were given
Do you mind having a look and see if the affected tests are being executed in the CI, if the classes are being used at all... I think we can probably clean up more than fixing the errors.
Thanks for the feedback, @datapythonista! Gonna do some exploring looking for what you mentioned then. |
Hey @datapythonista! Sorry for the delay. So, i didn't really know how to check if the tests were being executed in the CI, but i tried analyzing the classes on each test (how they are being used and for what purpose) and got to the conclusion that they're not wrong, just the parameters of the magic methods that are not entirely correct. I also checked if these cases appears in other places but they dont. I really want to help, so if you can give me some pointers i really would appreciate it! |
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.
LGTM
Sorry for the delay @hydratedguy. In general, there are few ways to check if a test is executed. One would be to check the list of skipped tests in one of the builds. The faster and most reliable could be to add an I had another look, and I think in this case it's not the tests that are not being used, but the functionality itself. What I'd try is to delete the |
Also, if you can please merge upstream into your branch, the CI should be working now. |
Thanks for the clean up @hydratedguy If in a follow up PR you want to try to delete these methods, which may not be needed, that would be great. |
i've changed some inconsistencies on some magic methods's parameters and removed a return from a object initialization