Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UP036 (outdated-version-block) is off-by-one for the target version #7902

Closed
oprypin opened this issue Oct 10, 2023 · 2 comments · Fixed by #7920
Closed

UP036 (outdated-version-block) is off-by-one for the target version #7902

oprypin opened this issue Oct 10, 2023 · 2 comments · Fixed by #7920
Labels
bug Something isn't working

Comments

@oprypin
Copy link

oprypin commented Oct 10, 2023

If my target-version is py38, I expect the condition if sys.version_info >= (3, 8): to be dropped but it isn't.
It gets dropped for py37, though.

This is a regression introduced in #7284 while fixing #7258.

A minimal code snippet that reproduces the bug.

import sys

if sys.version_info >= (3, 8):
    print('oh no')

expected:

print('oh no')

actual: (no lint and the file doesn't get fixed)

The command you invoked (e.g., ruff /path/to/file.py --fix), ideally including the --isolated flag.

ruff check test.py

The current Ruff settings (any relevant sections from your pyproject.toml).

[tool.ruff]
target-version = "py38"
select = ["UP036"]

The current Ruff version (ruff --version)

ruff 0.0.292
@tdulcet
Copy link

tdulcet commented Oct 11, 2023

Another related issue here is that indexing/slicing does not work:

import sys

if sys.version_info[:2] < (3, 7):
    print('oh no')
ruff --target-version py37 --select UP036 --isolated test.py

This if block should be removed, but nothing changes. Even the Ruff documentation suggests using this slice syntax here, so it should work as expected.

@zanieb
Copy link
Member

zanieb commented Oct 11, 2023

Thanks for the reports!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants