Ignore deprecated rules unless selected by exact code by LoicRiegel · Pull Request #20167 · astral-sh/ruff (original) (raw)
added 2 commits
…in a minor version increase
Breaking API change
Related to the command-line interface
labels
ntBre changed the title
Feat/ignore deprecated rules by unless selected by exact code Ignore deprecated rules unless selected by exact code
ntBre changed the base branch from main to brent/0.13.0
ntBre mentioned this pull request
2 tasks
ntBre pushed a commit that referenced this pull request
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 UP0won'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 deselectedntBre pushed a commit that referenced this pull request
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 UP0won'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 deselectedntBre pushed a commit that referenced this pull request
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 UP0won'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 deselectedntBre pushed a commit that referenced this pull request
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 UP0won'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 deselecteddcreager added a commit that referenced this pull request
- main: (26 commits)
Ignore deprecated rules unless selected by exact code (#20167)
Stabilize adding future import via config option (#20277)
[
flake8-errmsg] Stabilize extendingraw-string-in-exception(EM101) to support byte strings (#20273) Stabilize the remaining Airflow rules (#20250) [flake8-bugbear] Stabilize support for non-context-manager calls inassert-raises-exception(B017) (#20274) [flake8-commas] Stabilize support for trailing comma checks in type parameter lists (COM812,COM819) (#20275) [pygrep_hooks] Stabilize usingAsyncMockmethods ininvalid-mock-access(PGH005) (#20272) Stabilize new strategy for classifying imports as first party (#20268) [pylint] Stabilize ignoring__init__.pyforuseless-import-alias(PLC0414) (#20271) [pylint] Stabilize adding U+061C tobidirectional-unicode(PLE2502) (#20276) [flake8-simplify] Stabilize fix safety ofmultiple-with-statements(SIM117) (#20270) Stabilizepytest-raises-ambiguous-pattern(RUF043) (#20253) Stabilizef-string-number-format(FURB116) (#20247) [pyupgrade] Removenon-pep604-isinstance(UP038) (#19156) [pandas-vet] Removepandas-df-variable-name(PD901) (#19223) Remove deprecated macOS config file discovery (#19210) Stabilizeredundant-none-literal(PYI061) (#20236) Stabilizegeneric-not-last-base-class(PYI059) (#20246) Stabilizeuseless-class-metaclass-type(UP050) (#20230) Stabilizeos-symlink(PTH211) (#20229) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})