Split or ifs
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery refactoring id: split-or-ifs
Section titled “Sourcery refactoring id: split-or-ifs”Description:
Section titled “Description:”Splits out conditions combined with an or in an if statement into their own
if statement.
Before:
Section titled “Before:”if a or b: c()After:
Section titled “After:”if a: c()elif b: c()Explanation:
Section titled “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.