Repository navigation
Conversation
Parentheses wrapping an entire and/or condition (e.g. 'if (a and b):') are now reported. The blanket found_and_or pass is kept only where the parentheses are genuinely required: after 'not', and when the parenthesised expression is an operand of a following binary operator such as 'in'. Closes pylint-dev#10084
|
Assignment question on #10084 is resolved β @ranadheerg has handed it over (#10084 (comment)), so this is no longer stepping on anyone's work and is ready for review whenever someone has a moment. Recapping the state since it's been open a little while: All 900 functional tests pass, and running the updated check over pylint's own source yields no new hits beyond the three already present on |
Type of Changes
Description
superfluous-parens(C0325) gave a blanket pass to any parenthesised expression containingand/or, so conditions likeif (a is None and a is not None):were never reported β even though the same expression without boolean operators (e.g.if (a == 5):orK = ("a" + "b")) is reported. This makes theand/orexemption narrower, keeping it only where the parentheses are genuinely required:notβnot (a and b)parses differently without parens;(a or b) in c.Parentheses that wrap the entire statement expression (
if (a and b):,while (a or b):) are now reported. Multiline conditions are untouched (the existing NL bail-out), as are partial groupings likeif (a and b) or c:.This follows the same "narrow the historical blanket pass" approach as #11081 did for
in, which left this case explicitly out of scope. Existing functional suite passes (900 tests), and running the updated check over pylint's own source produces no new hits (the three pre-existing C0325 hits onmainare unchanged by this PR).Note: #10084 is assigned to @ranadheerg β I asked on the issue whether they're still working on it before opening this; happy to close this in favor of their PR if they are.
Closes #10084