Skip to content

Remove pass from elif

Sourcery refactoring id: remove-pass-elif

Description:

Removes a pass from the elif section of a conditional

Before:

if a:
    x()
elif b:
    pass
else:
    return c

After:

if a:
    x()
elif not b:
    return c

Explanation:

Reducing the number of branches in a conditional reduces the mental load of reading and understanding it considerably. This simplification can be made where an empty elif branch is immediately followed by the else.

Back to top