Skip to content

Remove Assert True

Sourcery refactoring id: remove-assert-true

Description

Remove assert True statements

Before

print("Checking things")
assert True
assert True, "Always true"
assert len([0, 1, 2]) >= 0, "This is also always true"
print("Done")

After

print("Checking things")
print("Done")

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.