ruff/docs/rules/combine-if-conditions.md
2023-02-12 21:00:32 +00:00

388 B

combine-if-conditions (SIM114)

Derived from the flake8-simplify linter.

What it does

Checks if consecutive if branches have the same body.

Why is this bad?

These branches can be combine using the python or statement

Example

if x = 1:
    print("Hello")
elif x = 2:
    print("Hello")

Use instead:

if x = 1 or x = 2
    print("Hello")