PY3.R1723
No else break
Used in order to highlight an unnecessary block of code following an if containing a break statement. As such, it will warn when it encounters an else following a chain of if s, all of them containing a break statement.
Noncompliant Code:
Copy
def next_seven_elements(iterator):
for i, item in enumerate(iterator):
if i == 7:
break
else:
yield item
Compliant Code:
Copy
def next_seven_elements(iterator):
for i, item in enumerate(iterator):
if i == 7:
break
yield item