-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
UP036
is flagging sys.version_info >= (3,)
checks but not sys.version_info.major >= 3
checks. Both cases should be flagged in the below example:
$ cat example.py
import sys
# flagged
if sys.version_info >= (3,):
print("3")
else:
print("2")
# not flagged
if sys.version_info.major >= 3:
print("3")
else:
print("2")
$ ruff --verbose check --select 'UP' --target-version 'py38' --isolated example.py
[2025-05-18][15:44:40][ruff::resolve][DEBUG] Isolated mode, not reading any pyproject.toml
[2025-05-18][15:44:40][ruff::commands::check][DEBUG] Identified files to lint in: 3.107ms
[2025-05-18][15:44:40][ruff::commands::check][DEBUG] Checked 1 files in: 19.042µs
example.py:4:4: UP036 Version block is outdated for minimum Python version
|
3 | # flagged
4 | if sys.version_info >= (3,):
| ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
5 | print("3")
6 | else:
|
= help: Remove outdated version block
Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
Real-life example here.
Version
ruff 0.11.10
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule