-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fix false positive for superfluous-parens
for return (a or b) in iterable
#5964
Fix false positive for superfluous-parens
for return (a or b) in iterable
#5964
Conversation
superfluous-parens
for return (a, b) in iterable
superfluous-parens
for return (a or b) in iterable
511ae04
to
f9ac563
Compare
f9ac563
to
6174fa8
Compare
Pull Request Test Coverage Report for Build 2044359428
💛 - Coveralls |
if keyword_token == "in": | ||
# This special case was added in https://github.com/PyCQA/pylint/pull/4948 | ||
# but it could be removed in the future. Avoid churn for now. | ||
return |
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.
@DanielNoord this is here to preserve the special case added in #4948, but when I looked into it, I had trouble figuring out why it was deemed a bugfix. (Looks like unnecessary parentheses to me!) Do you recall the thought behind 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.
Does this still pass:
D = [x for x in ((3, 4) if 1 > 0 else ((5, 6)))]
See #4907 (comment)
I think sometimes people want to create inner tuples and this was added so we don't flag those.
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.
Yes, it still passes now, but I'm essentially suggesting we later revert #4948.
I think sometimes people want to create inner tuples and this was added so we don't flag those.
I'm not sure what inner tuple means here. ((5,6),)
is a tuple of a tuple. ((5,6))
is superfluous parentheses, so it could just be disabled if people really prefer the extra parentheses. But I think maybe there's a nuance here I'm not getting?
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.
Does this still pass:
D = [x for x in ((3, 4) if 1 > 0 else ((5, 6)))]
(This test is still in the suite)
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 perhaps I was wrong to re-allow those.
I thought there might be use cases where you would want to create Tuple[Tuple[Tuple[int, ...]]]
instead of Tuple[int, ...]
?
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.
Sure, but that's (((5,),),)
rather than (((5,)))
.
Parentheses increase readability, so I understand why people use them, belt and suspenders and all, but I'm just saying those folks might not want the check enabled if they're in the practice of adding them.
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.
Hm, I'm fine with reverting then. But we should check #4907 for any legitimate use cases.
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'll capture this discussion on #5361
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, I'm thinking the changelog should be in 2.13.1 in ChangeLog and in 2.14 in whatsnew if we backport this but let me know what you think. (edit: resolved in another discussion)
if keyword_token == "in": | ||
# This special case was added in https://github.com/PyCQA/pylint/pull/4948 | ||
# but it could be removed in the future. Avoid churn for now. | ||
return |
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.
Does this still pass:
D = [x for x in ((3, 4) if 1 > 0 else ((5, 6)))]
See #4907 (comment)
I think sometimes people want to create inner tuples and this was added so we don't flag those.
@jacobtylerwalls Do we understand the coverage report? |
From the edit history of the comment the lines lost coverage when I merged main 10 hours ago, so ... yes? :D (I don't really have a mental model of how Coveralls handles merges into PR branches.) |
…terable` (#5964) Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Type of Changes
Description
Fix false positive for
superfluous-parens
for patterns likereturn (a or b) in iterable
.Closes #5803