Simplify Boolean Comparison
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: simplify-boolean-comparison
Section titled “Sourcery refactoring id: simplify-boolean-comparison”Description:
Section titled “Description:”Removes unnecessarily verbose boolean comparisons
Before:
Section titled “Before:”need_hat = not is_rainingif need_hat == True: put_on_hat()After:
Section titled “After:”need_hat = not is_rainingif need_hat: put_on_hat()Explanation:
Section titled “Explanation:”It is unnecessary to compare boolean values to True or False in the test of
an if condition. Removing these unnecessary checks makes the code slightly
shorter and easier to parse.