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

[pyupgrade] Handle micro version numbers correctly (UP036) #16091

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

InSyncWithFoo
Copy link
Contributor

Summary

Resolves #16082.

UP036 will now also take into consideration whether or not a micro version number is set:

  • If a third element doesn't exist, the existing logic is preserved.
  • If it exists but is not an integer literal, the check will not be reported.
  • If it is an integer literal but doesn't fit into a u8, the check will be reported as invalid.
  • Otherwise, the compared version is determined to always be less than the target version when:
    • The target's minor version is smaller than that of the comparator, or
    • The operator is <, the micro version is 0, and the two minor versions compare equal.

As this is considered a bugfix, it is not preview-gated.

Test Plan

cargo nextest run and cargo insta test.

Copy link
Contributor

github-actions bot commented Feb 11, 2025

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+2 -0 violations, +0 -0 fixes in 1 projects; 54 projects unchanged)

scikit-build/scikit-build-core (+2 -0 violations, +0 -0 fixes)

+ src/scikit_build_core/builder/sysconfig.py:170:39: RUF100 [*] Unused `noqa` directive (unused: `UP036`)
+ tests/test_pyproject_pep660.py:100:39: RUF100 [*] Unused `noqa` directive (unused: `UP036`)

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
RUF100 2 2 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+2 -0 violations, +0 -0 fixes in 1 projects; 54 projects unchanged)

scikit-build/scikit-build-core (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview

+ src/scikit_build_core/builder/sysconfig.py:170:39: RUF100 [*] Unused `noqa` directive (unused: `UP036`)
+ tests/test_pyproject_pep660.py:100:39: RUF100 [*] Unused `noqa` directive (unused: `UP036`)

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
RUF100 2 2 0 0 0

@MichaReiser MichaReiser added bug Something isn't working rule Implementing or modifying a lint rule labels Feb 11, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. It's great to see that this fixes two false positives

@MichaReiser MichaReiser enabled auto-merge (squash) February 11, 2025 07:37
@MichaReiser MichaReiser merged commit 7fbd89c into astral-sh:main Feb 11, 2025
20 checks passed
dcreager added a commit that referenced this pull request Feb 11, 2025
* main:
  add diagnostic `Span` (couples `File` and `TextRange`) (#16101)
  Remove `Hash` and `Eq` from `AstNodeRef` for types not implementing `Eq` or `Hash` (#16100)
  Fix release build warning about unused todo type message (#16102)
  [`pydocstyle`] Handle arguments with the same names as sections (`D417`) (#16011)
  [red-knot] Reduce usage of `From<Type>` implementations when working with `Symbol`s (#16076)
  Transition to salsa coarse-grained tracked structs (#15763)
  [`pyupgrade`] Handle micro version numbers correctly (`UP036`) (#16091)
  [red-knot] `T | object == object` (#16088)
  [`ruff`] Skip singleton starred expressions for `incorrectly-parenthesized-tuple-in-subscript` (`RUF031`) (#16083)
  Delete left-over `verbosity.rs (#16081)
  [red-knot] User-level configuration (#16021)
  Add `user_configuration_directory` to `System` (#16020)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UP036 doesn't handle three digit version numbers correctly
2 participants