Skip to content

Conversation

LoicRiegel
Copy link
Contributor

Summary

Closes #18349

After this change:

  • All deprecated rules are deselected by default
  • They are only selected if the user specifically selects them by code, e.g. --select UP038
  • Thus, --select ALL --select UP --select UP0 won't select the deprecated rule UP038
  • Documented the change in version policy. From now on, deprecating a rule should increase the minor version

Test Plan

Integration tests in "integration_tests.rs"

Also tested with a temporary test package:

~> ../../ruff/target/debug/ruff.exe check --select UP038
warning: Rule `UP038` is deprecated and will be removed in a future release.
warning: Detected debug build without --no-cache.
UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
 --> main.py:2:11
  |
1 | def main():
2 |     print(isinstance(25, (str, int)))
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
help: Convert to `X | Y`

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).

~> ../../ruff/target/debug/ruff.exe check --select UP03
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP0
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select ALL
# warnings and errors, but because of other errors, UP038 was deselected

@ntBre ntBre added this to the v0.13 milestone Sep 3, 2025
Copy link
Contributor

@ntBre ntBre 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! The code and docs changes look good to me, I just had a few nits about the tests.

Comment on lines 1472 to 1473
fn deprecated_selected_exact() {
// A deprecated rule should be included if selected by exact code
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a pretty small nit, but I'd lean toward not changing any names or comments unless they're really outdated. I think this case, and deprecated_multiple_direct at least were okay with the old names.

Comment on lines 1514 to 1515
fn deprecated_selected_prefix() {
// A deprecated rule should not be included if selected by rule prefix
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the above, I think the name here was okay. But the new comment makes sense to me given the changed test result.

@@ -1549,38 +1542,38 @@ fn deprecated_direct_preview_enabled() {
}

#[test]
fn deprecated_indirect_preview_enabled() {
// `RUF920` is deprecated and should be off by default in preview.
fn deprecated_selected_exact_multiple_preview_enabled() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd kind of prefer to preserve the existing tests and add new ones rather than modify these, unless they're now redundant with other tests. Is that the case?

@ntBre ntBre added breaking Breaking API change cli Related to the command-line interface labels Sep 3, 2025
@ntBre
Copy link
Contributor

ntBre commented Sep 3, 2025

I also labeled this breaking, as Micha mentioned here. But we're preparing for a minor release next week, so we can merge this into the release branch instead of main. GitHub warned me that changing the base branch might remove review comments, though, so I held off for now.

Copy link
Contributor

github-actions bot commented Sep 3, 2025

ruff-ecosystem results

Linter (stable)

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

rotki/rotki (+0 -1 violations, +0 -0 fixes)

- rotkehlchen/externalapis/blockscout.py:205:40: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
UP038 1 0 1 0 0

Linter (preview)

✅ ecosystem check detected no linter changes.

@LoicRiegel
Copy link
Contributor Author

Thank you for the review, I will make the changes now.
Do you want me to keep the commit history clean, or will you squash everything anyway?

@ntBre
Copy link
Contributor

ntBre commented Sep 3, 2025

Thank you! We'll squash everything when merging, so it's actually a bit easier to review if you push additional commits, in my opinion

@LoicRiegel
Copy link
Contributor Author

I just pushed three commits where

  • I reverted the tests to the way they were
  • Wrote comments for all tests concerned by this change so they are more precise and all consistent
  • I swapped two tests to make the order consistent, I hope that's okay

Tell me if everything's alright now :)

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks! Just a few more test suggestions to reduce the diff a bit more. I have a better understanding of the tests now and think they mostly still look relevant in their original form.

@LoicRiegel
Copy link
Contributor Author

Thanks! Just a few more test suggestions to reduce the diff a bit more. I have a better understanding of the tests now and think they mostly still look relevant in their original form.

Done :)
Now the diff is as small as it can be :)

Copy link
Contributor

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

@ntBre ntBre changed the title Feat/ignore deprecated rules by unless selected by exact code Ignore deprecated rules unless selected by exact code Sep 8, 2025
@ntBre ntBre changed the base branch from main to brent/0.13.0 September 8, 2025 15:59
@ntBre ntBre merged commit 4149d64 into astral-sh:brent/0.13.0 Sep 8, 2025
35 checks passed
@ntBre ntBre mentioned this pull request Sep 8, 2025
2 tasks
ntBre pushed a commit that referenced this pull request Sep 8, 2025
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

Closes #18349

After this change:
- All deprecated rules are deselected by default
- They are only selected if the user specifically selects them by code,
e.g. `--select UP038`
- Thus, `--select ALL --select UP --select UP0` won't select the
deprecated rule UP038
- Documented the change in version policy. From now on, deprecating a
rule should increase the minor version

## Test Plan

Integration tests in "integration_tests.rs"

Also tested with a temporary test package:
```
~> ../../ruff/target/debug/ruff.exe check --select UP038
warning: Rule `UP038` is deprecated and will be removed in a future release.
warning: Detected debug build without --no-cache.
UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
 --> main.py:2:11
  |
1 | def main():
2 |     print(isinstance(25, (str, int)))
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
help: Convert to `X | Y`

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).

~> ../../ruff/target/debug/ruff.exe check --select UP03
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP0
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select ALL
# warnings and errors, but because of other errors, UP038 was deselected
```
ntBre pushed a commit that referenced this pull request Sep 10, 2025
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

Closes #18349

After this change:
- All deprecated rules are deselected by default
- They are only selected if the user specifically selects them by code,
e.g. `--select UP038`
- Thus, `--select ALL --select UP --select UP0` won't select the
deprecated rule UP038
- Documented the change in version policy. From now on, deprecating a
rule should increase the minor version

## Test Plan

Integration tests in "integration_tests.rs"

Also tested with a temporary test package:
```
~> ../../ruff/target/debug/ruff.exe check --select UP038
warning: Rule `UP038` is deprecated and will be removed in a future release.
warning: Detected debug build without --no-cache.
UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
 --> main.py:2:11
  |
1 | def main():
2 |     print(isinstance(25, (str, int)))
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
help: Convert to `X | Y`

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).

~> ../../ruff/target/debug/ruff.exe check --select UP03
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP0
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select ALL
# warnings and errors, but because of other errors, UP038 was deselected
```
ntBre pushed a commit that referenced this pull request Sep 10, 2025
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

Closes #18349

After this change:
- All deprecated rules are deselected by default
- They are only selected if the user specifically selects them by code,
e.g. `--select UP038`
- Thus, `--select ALL --select UP --select UP0` won't select the
deprecated rule UP038
- Documented the change in version policy. From now on, deprecating a
rule should increase the minor version

## Test Plan

Integration tests in "integration_tests.rs"

Also tested with a temporary test package:
```
~> ../../ruff/target/debug/ruff.exe check --select UP038
warning: Rule `UP038` is deprecated and will be removed in a future release.
warning: Detected debug build without --no-cache.
UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
 --> main.py:2:11
  |
1 | def main():
2 |     print(isinstance(25, (str, int)))
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
help: Convert to `X | Y`

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).

~> ../../ruff/target/debug/ruff.exe check --select UP03
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP0
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select ALL
# warnings and errors, but because of other errors, UP038 was deselected
```
ntBre pushed a commit that referenced this pull request Sep 10, 2025
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

Closes #18349

After this change:
- All deprecated rules are deselected by default
- They are only selected if the user specifically selects them by code,
e.g. `--select UP038`
- Thus, `--select ALL --select UP --select UP0` won't select the
deprecated rule UP038
- Documented the change in version policy. From now on, deprecating a
rule should increase the minor version

## Test Plan

Integration tests in "integration_tests.rs"

Also tested with a temporary test package:
```
~> ../../ruff/target/debug/ruff.exe check --select UP038
warning: Rule `UP038` is deprecated and will be removed in a future release.
warning: Detected debug build without --no-cache.
UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
 --> main.py:2:11
  |
1 | def main():
2 |     print(isinstance(25, (str, int)))
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
help: Convert to `X | Y`

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).

~> ../../ruff/target/debug/ruff.exe check --select UP03
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP0
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select UP
warning: Detected debug build without --no-cache.
All checks passed!

~> ../../ruff/target/debug/ruff.exe check --select ALL
# warnings and errors, but because of other errors, UP038 was deselected
```
dcreager added a commit that referenced this pull request Sep 10, 2025
* main: (26 commits)
  Ignore deprecated rules unless selected by exact code (#20167)
  Stabilize adding future import via config option (#20277)
  [`flake8-errmsg`] Stabilize extending `raw-string-in-exception` (`EM101`) to support byte strings (#20273)
  Stabilize the remaining Airflow rules (#20250)
  [`flake8-bugbear`] Stabilize support for non-context-manager calls in `assert-raises-exception` (`B017`) (#20274)
  [`flake8-commas`] Stabilize support for trailing comma checks in type parameter lists (`COM812`, `COM819`) (#20275)
  [`pygrep_hooks`] Stabilize using`AsyncMock` methods in `invalid-mock-access` (`PGH005`) (#20272)
  Stabilize new strategy for classifying imports as first party (#20268)
  [`pylint`] Stabilize ignoring `__init__.py` for `useless-import-alias` (`PLC0414`) (#20271)
  [`pylint`] Stabilize adding U+061C to `bidirectional-unicode` (`PLE2502`) (#20276)
  [`flake8-simplify`] Stabilize fix safety of `multiple-with-statements` (`SIM117`) (#20270)
  Stabilize `pytest-raises-ambiguous-pattern` (`RUF043`) (#20253)
  Stabilize `f-string-number-format` (`FURB116`) (#20247)
  [`pyupgrade`] Remove `non-pep604-isinstance` (`UP038`) (#19156)
  [`pandas-vet`] Remove `pandas-df-variable-name` (`PD901`) (#19223)
  Remove deprecated macOS config file discovery (#19210)
  Stabilize `redundant-none-literal` (`PYI061`) (#20236)
  Stabilize `generic-not-last-base-class` (`PYI059`) (#20246)
  Stabilize `useless-class-metaclass-type` (`UP050`) (#20230)
  Stabilize `os-symlink` (`PTH211`) (#20229)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking API change cli Related to the command-line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn about error being related to a deprecated rule
2 participants