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
Only emit bad-reversed-sequence
on dictionaries if below py3.8 (#3940)
#3958
Only emit bad-reversed-sequence
on dictionaries if below py3.8 (#3940)
#3958
Conversation
Thanks for the merge request @ethan-leba, very clean ! I saw in the linked issue that the original poster said it's fine for "Python 3.7 and up", so shouldn't it be only below 3.7 instead of 3.8 ? |
Thanks! I think the poster of the original issue must've been mistaken, as it appears this change was introduced in Py3.8 (see 5th bullet point here) |
Thanks you for the doc, you're right :) Also, I wonder if everything in the test case before line 62 could be in a functional test used for all version of python ? Isn't the dict test the only one that is specific to python 3.8 and above ? |
13867ec
to
cd92066
Compare
As a consequence, pylint will only emit `bad-reversed-sequence` on dictionaries if below py3.8, as a `__reversed__` dunder was added to dicts on py3.8
cd92066
to
c147e55
Compare
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.
Addressed the redundancies in the functional tests, also decided to take a slightly different approach to this fix
if argument._proxied.name == "dict" and utils.is_builtin_object( | ||
argument._proxied | ||
): | ||
self.add_message("bad-reversed-sequence", node=node) | ||
return | ||
if any( | ||
ancestor.name == "dict" and utils.is_builtin_object(ancestor) | ||
for ancestor in argument._proxied.ancestors() | ||
for ancestor in itertools.chain( | ||
(argument._proxied,), argument._proxied.ancestors() | ||
) | ||
): |
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.
Instead of a check for the system version, I removed the hardcoded add_message
on dicts. We should be able to find the __reversed__
dunder on py3.8 but not >py3.7, which i think should address this bug in a cleaner way IMO. I think the performance should be the same, but LMK if this seems too slow, or if there's a reason why this might not work!
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.
Wow, that MR that took a 360 ..for the better :D Actually one minor comment, you do not need the empty bad_reversed_sequence_py38.txt
anymore, thanks to a fresh commit from this afternoon ;)
c147e55
to
d095b19
Compare
d095b19
to
bf1d1e0
Compare
@Pierre-Sassoulas Deleted the empty text file, LMK if there's any other changes that need to be made π |
Description
Only emit
bad-reversed-sequence
on dictionaries if below py3.8Type of Changes
Related Issue
Closes #3940