Skip to content

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

Merged
zanieb merged 3 commits into
mainfrom
zanie/fix-outdated-version-block
Oct 11, 2023
Merged

zanieb merged 3 commits into
mainfrom
zanie/fix-outdated-version-block

Conversation

@zanieb

@zanieb zanieb commented Oct 11, 2023 •

Copy link
Copy Markdown
Member

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

github-actions Bot commented Oct 11, 2023 •

Copy link
Copy Markdown
Contributor

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

zanieb commented Oct 11, 2023

Copy link
Copy Markdown
Member Author

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
@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