Skip to content

outdated-version-block

Pythonsuspiciousno fixdefault: offpython/ruff

Reports a test of sys.version_info against a version older than the target_version, or of sys.version_info[0] against a number.

For the target version the answer of the test is always the same, so one of the branches never runs and the other needs no test. It is a block that was kept after support for the old version ended.

To fix, remove the test and keep the branch that runs.

Reported
...
import sys
if sys.version_info >= (3, 8):
pass
from typing import TypeVar
...
python:
lint:
rules:
outdated-version-block: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line outdated-version-block in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff UP036 full