Boolean If Expression Identity
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: boolean-if-exp-identity
Section titled “Sourcery refactoring id: boolean-if-exp-identity”Description:
Section titled “Description:”Simplifies boolean if expressions by removing unnecessary explicit references to
True or False states
Before:
Section titled “Before:”some_var = True if some_boolean_expression else FalseAfter:
Section titled “After:”some_var = some_boolean_expressionExplanation:
Section titled “Explanation:”Rather than using an if-expression to evaluate a boolean, you can just use it directly. This is shorter and clearer - if expressions of this form take a while to mentally parse.
Where Sourcery cannot determine if the expression is a boolean it will wrap it
in a call tobool().