Skip to content

Remove Redundant Condition

Sourcery refactoring id: remove-redundant-condition

Description:

Remove a redundant condition used during variable assignment

Before:

x = y if z else y

After:

x = y

Explanation:

Code may contain redundant statements where a condition is unnecessarily evaluated, and the result will be the same either way. This refactoring detects such redundancy and removes it.

Back to top