Skip to content

Simplify Numeric Comparison

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: simplify-numeric-comparison

Section titled “Sourcery refactoring id: simplify-numeric-comparison”

Consolidates any mathematical operations in a numeric comparison so there is a direct comparison of variable to number

if a + 1 < 2:
do_x()
if a < 1:
do_x()

This refactoring removes unnecessary clutter from the code and makes it easier to determine what a variable is being compared to.