-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
PLR1702 spam #15570
Comments
PLR1702 is currently marking every line inside this function: def foo():
while a: # should not be marked - not a violation
if b: # should not be marked - not a violation
for c in range(3): # should not be marked - not a violation
if d: # should not be marked - not a violation
while e: # should not be marked - not a violation
if f: # should not be marked - not a violation
for g in z: # not bad to mark this line, but not needed if only marking the max
print(p) # this line should be marked
pass # this line doesn't need to be marked, because the previous line is marked
else: # should not be marked - not a violation
print(q) # should not be marked - not a violation |
Here's an example with multiple diagnostics. def foo():
while a: # should not be marked - not a violation
if b: # should not be marked - not a violation
for c in range(3): # should not be marked - not a violation
if d: # should not be marked - not a violation
while e: # should not be marked - not a violation
if f: # should not be marked - not a violation
for g in z: # not bad to mark this line, but not needed if only marking the max
print(p) # this line should be marked
pass # this line doesn't need to be marked, because the previous line is marked
else:
if h:
print(r)
else: # should not be marked - not a violation
print(q) # should not be marked - not a violation |
In the original example of the first screenshot, there 250 lines all completely highlighted, making it difficult to see other diagnostics. If there are 5 violations, highlighting 5 lines is enough. |
Thank you, that's helpful! I think there's a small design question about how to handle this situation, and we should be conscious of whether we are creating a breaking change by modifying where a suppression comment can go. But I agree that we can do better here. |
If a function has nested blocks to violate PLR1702, almost the entire function is marked for it, including lines that are not violations.
Even lines that are only nested 2 or 3 deep are marked with squigglies.
Even when there are multiple lines in a block nested 9 deep, I think it would be enough to only mark the first line of that deeply nested block.
The text was updated successfully, but these errors were encountered: