-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Ignore deprecated rules unless selected by exact code #20167
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
Ignore deprecated rules unless selected by exact code #20167
Conversation
There was a problem hiding this 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.
fn deprecated_selected_exact() { | ||
// A deprecated rule should be included if selected by exact code |
There was a problem hiding this comment.
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.
fn deprecated_selected_prefix() { | ||
// A deprecated rule should not be included if selected by rule prefix |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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?
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 |
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
UP038 | 1 | 0 | 1 | 0 | 0 |
Linter (preview)
✅ ecosystem check detected no linter changes.
Thank you for the review, I will make the changes now. |
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 |
I just pushed three commits where
Tell me if everything's alright now :) |
There was a problem hiding this 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.
Done :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
<!-- 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 ```
<!-- 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 ```
<!-- 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 ```
<!-- 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 ```
* 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) ...
Summary
Closes #18349
After this change:
--select UP038
--select ALL --select UP --select UP0
won't select the deprecated rule UP038Test Plan
Integration tests in "integration_tests.rs"
Also tested with a temporary test package: