Remove Assert True
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-assert-true
Section titled “Sourcery refactoring id: remove-assert-true”Description
Section titled “Description”Remove assert True statements
Before
Section titled “Before”print("Checking things")assert Trueassert True, "Always true"assert len([0, 1, 2]) >= 0, "This is also always true"print("Done")print("Checking things")print("Done")Explanation
Section titled “Explanation”Assertions are useful to make sure that some conditions hold during the execution of a program. However, when the expression being evaluated is always true, no assertion is necessary, and removing it makes code simpler and easier to understand.