Skip to content

Remove Redundant Condition

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-condition

Section titled “Sourcery refactoring id: remove-redundant-condition”

Remove a redundant condition used during variable assignment

x = y if z else y
x = y

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.