Skip to content

Split or ifs

Sourcery refactoring id: split-or-ifs

Description:

Splits out conditions combined with an or in an if statement into their own if statement.

Before:

if a or b:
    c()

After:

if a:
    c()
elif b:
    c()

Explanation:

It is logically equivalent to transform an or condition into an if branch and an elif branch of a conditional. This is not prima facie an improvement to the code, but it can unlock further improvements, and Sourcery will only make this change if such improvements are possible.