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

Fix false negative in outdated-version-block when using greater than comparisons #7920

Merged
merged 3 commits into from
Oct 11, 2023

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Oct 11, 2023

Closes #7902

# With target version of Python 3.7
import sys

if sys.version_info >= (3, 7):  # ERROR: UP036
    print('oh no')

if sys.version_info <= (3, 7):  # OK: Can evaluate to different value sometimes e.g. version 3.7 vs 3.8
    print('oh no')

if sys.version_info < (3, 7):  # ERROR: UP036
    print('oh no')

if sys.version_info > (3, 7):  # OK: Can evaluate to different value sometimes e.g. version 3.7 vs 3.8
    print('oh no')

if sys.version_info < (3, 6):  # ERROR: UP036
    print('oh no')

if sys.version_info > (3, 6):  # ERROR: UP036
    print('oh no')

if sys.version_info < (3, 8):  # OK: Can evaluate to a different value sometimes e.g. 3.7 vs 3.8
    print('oh no')

if sys.version_info > (3, 8):  # OK: Can evaluate to a different value sometimes e.g. 3.7 vs 3.9
    print('oh no')

@github-actions
Copy link
Contributor

github-actions bot commented Oct 11, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@zanieb zanieb force-pushed the zanie/fix-outdated-version-block branch from e3406be to ff1b254 Compare October 11, 2023 16:26
@zanieb
Copy link
Member Author

zanieb commented Oct 11, 2023

Following the one line fix, I've made some refactors for readability that have no effect on behavior.

@zanieb zanieb marked this pull request as ready for review October 11, 2023 16:32
@zanieb zanieb merged commit 23bbe73 into main Oct 11, 2023
16 checks passed
@zanieb zanieb deleted the zanie/fix-outdated-version-block branch October 11, 2023 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UP036 (outdated-version-block) is off-by-one for the target version
2 participants