Remove Redundant Boolean
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: remove-redundant-boolean
Section titled “Sourcery refactoring id: remove-redundant-boolean”Description
Section titled “Description”Removes redundant booleans from tests.
Before
Section titled “Before”hat_prices = []while True and hat in hats: hat_prices.append(hat.price) hats.remove(hat)
assert len(hat_prices) > 10 and Falsewhile hat in hats: hat_prices.append(hat.price) hats.remove(hat)
assert FalseExplanation
Section titled “Explanation”Boolean values like True or False in boolean operations like and or or
may be redundant, and can be removed to simplify the code without affecting its
functionality. This refactoring will often compose with other refactorings where
boolean operations have been combined.
See also: remove-redundant-if