break-in-finally / W0137ΒΆ

Message emitted:

'break' discouraged inside 'finally' clause

Description:

Emitted when the `break` keyword is found inside a finally clause. This will raise a SyntaxWarning starting in Python 3.14.

Problematic code:

while True:
    try:
        pass
    finally:
        break  # [break-in-finally]

Correct code:

while True:
    try:
        pass
    except ValueError:
        pass
    else:
        break

Related links:

Created by the basic checker.