Invalid error reported for R507 because of some complex context
What I Did
We have some if...elif... clause like this:
def main():
for a in range(10): # | 0 div 4
if a % 4 == 0: # | 1 div nothing
print(a, 'div', 4) # | 2 div 2
elif a % 3 == 0: # | 3 div 3
print(a, 'div', 3) # | 4 div 4
continue # | 5 div nothing
elif a % 2 == 0: # | 6 div 3
print(a, 'div', 2) # | 7 div nothing
else: # | 8 div 4
print(a, 'div', 'nothing') # | 9 div 3
return 0
if __name__ == '__main__':
main()
For this case we are getting this error:
myfile.py:5:9: R507 unnecessary elif after continue statement.
elif a % 3 == 0:
^
If we follow the suggestion and fix the issue, then we have different output:
def main(): # | 0 div 4
for a in range(10): # | 0 div 2
if a % 4 == 0: # | 1 div nothing
print(a, 'div', 4) # | 2 div 2
elif a % 3 == 0: # | 3 div 3
print(a, 'div', 3) # | 4 div 4
continue # | 4 div 2
if a % 2 == 0: # | 5 div nothing
print(a, 'div', 2) # | 6 div 3
else: # | 7 div nothing
print(a, 'div', 'nothing') # | 8 div 4
return 0 # | 8 div 2
# | 9 div 3
if __name__ == '__main__':
main()
Can we do something to this? I have tried to apply the suggested errors on our codebase and this issue appeared.
Description
Invalid error reported for R507 because of some complex context
What I Did
We have some
if...elif...
clause like this:For this case we are getting this error:
If we follow the suggestion and fix the issue, then we have different output:
Can we do something to this? I have tried to apply the suggested errors on our codebase and this issue appeared.