-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Ruff 0.12 #18427
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
Merged
Merged
Ruff 0.12 #18427
Conversation
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
5f1af44
to
11966be
Compare
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PLC0415 | 6021 | 6021 | 0 | 0 | 0 |
UP045 | 3082 | 3082 | 0 | 0 | 0 |
UP007 | 857 | 0 | 857 | 0 | 0 |
PD901 | 431 | 0 | 431 | 0 | 0 |
RET503 | 289 | 134 | 155 | 0 | 0 |
FBT001 | 224 | 224 | 0 | 0 | 0 |
PT031 | 159 | 159 | 0 | 0 | 0 |
PLW1641 | 152 | 152 | 0 | 0 | 0 |
PLW0177 | 94 | 94 | 0 | 0 | 0 |
PT028 | 91 | 91 | 0 | 0 | 0 |
S603 | 70 | 0 | 70 | 0 | 0 |
RUF100 | 36 | 23 | 13 | 0 | 0 |
PT030 | 34 | 34 | 0 | 0 | 0 |
RUF005 | 21 | 21 | 0 | 0 | 0 |
PLR1733 | 19 | 19 | 0 | 0 | 0 |
LOG014 | 16 | 16 | 0 | 0 | 0 |
SIM108 | 13 | 8 | 5 | 0 | 0 |
FURB122 | 10 | 10 | 0 | 0 | 0 |
FURB129 | 10 | 0 | 0 | 10 | 0 |
PYI044 | 8 | 0 | 0 | 8 | 0 |
FURB157 | 4 | 4 | 0 | 0 | 0 |
RUF058 | 3 | 3 | 0 | 0 | 0 |
FURB132 | 2 | 2 | 0 | 0 | 0 |
D400 | 2 | 1 | 1 | 0 | 0 |
SyntaxError: | 1 | 1 | 0 | 0 | 0 |
RUF028 | 1 | 1 | 0 | 0 | 0 |
FURB166 | 1 | 1 | 0 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+0 -431 violations, +0 -0 fixes in 3 projects; 52 projects unchanged)
apache/airflow (+0 -72 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
- airflow-core/src/airflow/example_dags/tutorial_objectstorage.py:93:9: PD901 Avoid using the generic variable name `df` for DataFrames - airflow-core/src/airflow/serialization/serializers/pandas.py:68:9: PD901 Avoid using the generic variable name `df` for DataFrames - dev/airflow_perf/sql_queries.py:186:5: PD901 Avoid using the generic variable name `df` for DataFrames - dev/stats/explore_pr_candidates.ipynb:cell 3:23:5: PD901 Avoid using the generic variable name `df` for DataFrames - providers/amazon/tests/unit/amazon/aws/transfers/test_sql_to_s3.py:232:9: PD901 Avoid using the generic variable name `df` for DataFrames - providers/amazon/tests/unit/amazon/aws/transfers/test_sql_to_s3.py:283:9: PD901 Avoid using the generic variable name `df` for DataFrames - providers/amazon/tests/unit/amazon/aws/transfers/test_sql_to_s3.py:326:9: PD901 Avoid using the generic variable name `df` for DataFrames - providers/apache/drill/tests/unit/apache/drill/hooks/test_drill.py:116:9: PD901 Avoid using the generic variable name `df` for DataFrames - providers/apache/drill/tests/unit/apache/drill/hooks/test_drill.py:99:9: PD901 Avoid using the generic variable name `df` for DataFrames - providers/apache/druid/tests/unit/apache/druid/hooks/test_druid.py:461:9: PD901 Avoid using the generic variable name `df` for DataFrames ... 62 additional changes omitted for project
apache/superset (+0 -268 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
- superset/charts/client_processing.py:110:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:112:13: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:113:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:114:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:124:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:132:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:136:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:141:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:144:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:147:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:206:17: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:213:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:341:13: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:343:13: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:91:5: PD901 Avoid using the generic variable name `df` for DataFrames - superset/charts/client_processing.py:95:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/commands/database/uploaders/csv_reader.py:135:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/commands/database/uploaders/excel_reader.py:108:13: PD901 Avoid using the generic variable name `df` for DataFrames - superset/commands/dataset/importers/v1/utils.py:207:5: PD901 Avoid using the generic variable name `df` for DataFrames - superset/commands/report/alert.py:179:17: PD901 Avoid using the generic variable name `df` for DataFrames - superset/commands/report/alert.py:204:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/commands/sql_lab/export.py:104:13: PD901 Avoid using the generic variable name `df` for DataFrames - superset/commands/sql_lab/export.py:128:13: PD901 Avoid using the generic variable name `df` for DataFrames - superset/common/query_actions.py:104:5: PD901 Avoid using the generic variable name `df` for DataFrames - superset/common/query_context_processor.py:268:9: PD901 Avoid using the generic variable name `df` for DataFrames - superset/common/query_context_processor.py:275:13: PD901 Avoid using the generic variable name `df` for DataFrames - superset/common/query_context_processor.py:279:17: PD901 Avoid using the generic variable name `df` for DataFrames - superset/common/query_context_processor.py:287:17: PD901 Avoid using the generic variable name `df` for DataFrames - superset/common/query_context_processor.py:602:13: PD901 Avoid using the generic variable name `df` for DataFrames - superset/common/query_context_processor.py:658:17: PD901 Avoid using the generic variable name `df` for DataFrames - superset/common/query_context_processor.py:665:17: PD901 Avoid using the generic variable name `df` for DataFrames ... 237 additional changes omitted for project
bokeh/bokeh (+0 -91 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
- examples/basic/annotations/band.py:21:1: PD901 Avoid using the generic variable name `df` for DataFrames - examples/basic/annotations/band.py:25:1: PD901 Avoid using the generic variable name `df` for DataFrames - examples/basic/annotations/polygon_annotation.py:12:1: PD901 Avoid using the generic variable name `df` for DataFrames - examples/basic/areas/stacked_area.py:16:1: PD901 Avoid using the generic variable name `df` for DataFrames - examples/basic/axes/datetime_axis.py:6:1: PD901 Avoid using the generic variable name `df` for DataFrames - examples/basic/bars/intervals.py:14:1: PD901 Avoid using the generic variable name `df` for DataFrames - examples/interaction/legends/legend_hide.py:22:5: PD901 Avoid using the generic variable name `df` for DataFrames - examples/interaction/legends/legend_mute.py:11:5: PD901 Avoid using the generic variable name `df` for DataFrames - examples/models/daylight.py:24:1: PD901 Avoid using the generic variable name `df` for DataFrames - examples/models/trail.py:36:5: PD901 Avoid using the generic variable name `df` for DataFrames ... 81 additional changes omitted for project
Changes by rule (1 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PD901 | 431 | 0 | 431 | 0 | 0 |
351e674
to
4cfaa39
Compare
6391de8
to
85bdb1e
Compare
…18496) Note that the preview behavior was not documented (shame on us!) so the documentation was not modified. --------- Co-authored-by: Brent Westbrook <[email protected]>
…eral-concatenation` (`RUF005`) (#18500)
This PR stabilizes the RUF053 rule by moving it from preview to stable status for the 0.12.0 release. ## Summary - **Rule**: RUF053 (`class-with-mixed-type-vars`) - **Purpose**: Detects classes that have both PEP 695 type parameter lists while also inheriting from `typing.Generic` - **Change**: Move from `RuleGroup::Preview` to `RuleGroup::Stable` in `codes.rs` and migrate preview tests to stable tests ## Verification Links - **Tests**: [ruff/mod.rs](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/ruff/mod.rs#L98) - Shows RUF053 moved from preview_rules to main rules test function - **Documentation**: https://docs.astral.sh/ruff/rules/class-with-mixed-type-vars/ - Current documentation shows preview status that will be automatically updated
This PR stabilizes the FURB162 rule by moving it from preview to stable status for the 0.12.0 release. ## Summary - **Rule**: FURB162 (`fromisoformat-replace-z`) - **Purpose**: Detects unnecessary timezone replacement operations when calling `datetime.fromisoformat()` - **Change**: Move from `RuleGroup::Preview` to `RuleGroup::Stable` in `codes.rs` ## Verification Links - **Tests**: [refurb/mod.rs](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/refurb/mod.rs#L54) - Confirms FURB162 has only standard tests, no preview-specific test cases - **Documentation**: https://docs.astral.sh/ruff/rules/fromisoformat-replace-z/ - Current documentation shows preview status that will be automatically updated
…sions in autofix for `if-else-block-instead-of-if-exp` (`SIM108`) (#18506)
…` (`RUF100`) (#18497) Note that the preview behavior was not documented (shame on us!) so the documentation was not modified. --------- Co-authored-by: Brent Westbrook <[email protected]>
…t-shell-equals-true` (`S603`) (#18521)
…ype-hint-positional-argument` (`FBT001`) (#18520) Feel free to complain about the rephrasing in the docs!
## Summary Stabilizes the UP049 rule (private-type-parameter) by moving it from Preview to Stable. UP049 detects and fixes the use of private type parameters (those with leading underscores) in PEP 695 generic classes and functions. ## Test plan - Verified that UP049 tests pass: `crates/ruff_linter/src/rules/pyupgrade/mod.rs` - Ran full test suite with `make test` - Confirmed that no test migration was needed as UP049 was already in the main `rules` test function ## Rule documentation https://docs.astral.sh/ruff/rules/private-type-parameter/
…d preview behavior for `non-pep604-annotation-union` (`UP007`) (#18505)
…14`) (#18517) ## Summary - Stabilizes LOG014 (exc-info-outside-except-handler) rule by changing it from Preview to Stable ## Test plan - ✅ Rule is already tested in main test function, no migration needed - ✅ `make check` passes - ✅ `make test` passes ## Rule Documentation - [Test file](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/flake8_logging/mod.rs#L22-L23) - [Rule documentation](https://docs.astral.sh/ruff/rules/exc-info-outside-except-handler/)
## Summary - Stabilizes RUF058 (starmap-zip) rule by changing it from Preview to Stable - Migrates test cases from preview_rules to main rules function - Updates snapshots accordingly and removes old preview snapshots ## Test plan - ✅ Migrated tests from preview to main test function - ✅ `make check` passes - ✅ `make test` passes - ✅ `make citest` passes (no leftover snapshots) ## Rule Documentation - [Test file](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/ruff/mod.rs#L103-L104) - [Rule documentation](https://docs.astral.sh/ruff/rules/starmap-zip/)
Co-authored-by: Brent Westbrook <[email protected]>
Co-authored-by: Brent Westbrook <[email protected]>
Summary -- Deprecates PD901 as part of #7710. I don't feel particularly strongly about this one, though I have certainly used `df` as a dataframe name in the past, just going through the open issues in the 0.12 milestone. Test Plan -- N/a
## Summary - Stabilizes UP046 (non-pep695-generic-class) rule by changing it from Preview to Stable ## Test plan - ✅ Rule is already tested in main test function, no migration needed - ✅ `make check` passes - ✅ `make test` passes ## Rule Documentation - [Test file](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/pyupgrade/mod.rs#L109-L110) - [Rule documentation](https://docs.astral.sh/ruff/rules/non-pep695-generic-class/)
## Summary - Stabilizes UP047 (non-pep695-generic-function) rule by changing it from Preview to Stable ## Test plan - ✅ Rule is already tested in main test function, no migration needed - ✅ `make check` passes - ✅ `make test` passes ## Rule Documentation - [Test file](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/pyupgrade/mod.rs#L111) - [Rule documentation](https://docs.astral.sh/ruff/rules/non-pep695-generic-function/)
…xing `implicit-return` (`RET503`) (#18516) This involved slightly more code changes than usual for a stabilization - so maybe worth double-checking the logic! I did verify by hand that the new stable behavior on the test fixture matches the old preview behavior, even after the internal refactor.
85bdb1e
to
dad0ecd
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Release branch for Ruff 0.12.0
Breaking changes
}
when f-string expression has a format specifier #18704Behavior changes
ruff
] Stabilize checking in presence of slices forcollection-literal-concatenation
(RUF005
) #18500refurb
] Stabilize fix safety forreadlines-in-for
(FURB129
) #18496flake8-simplify
] Stabilize further simplification to binary expressions in autofix forif-else-block-instead-of-if-exp
(SIM108
) #18506ruff
] Stabilize checking for file-level directives inunused-noqa
(RUF100
) #18497flake8-pyi
] Stabilize autofix forfuture-annotations-in-stub
(PYI044
) #18518flake8-bandit
] Stabilize more trusted inputs insubprocess-without-shell-equals-true
(S603
) #18521flake8-boolean-trap
] Stabilize lintbool
suprtypes inboolean-type-hint-positional-argument
(FBT001
) #18520pyupgrade
] Stabilizenon-pep604-annotation-optional
(UP045
) and preview behavior fornon-pep604-annotation-union
(UP007
) #18505flake8-return
] Stabilize only addreturn None
at the end when fixingimplicit-return
(RET503
) #18516Recoded rules
Deprecated rules
pandas-vet
] Deprecatepandas-df-variable-name
(PD901
) #18618Changed rules
Removed rules
flake8-bandit
] Removesuspicious-xmle-tree-usage
(S320
) #18617Stabilized rules
class-with-mixed-type-vars
(RUF053) #18512fromisoformat-replace-z
(FURB162) #18510verbose-decimal-constructor
(FURB157
) #18556ruff
] Stabilizeinvalid-formatter-suppression-comment
(RUF028
) #18555pylint
] Stabilizeimport-outside-top-level
(PLC0415
) #18554int-on-sliced-str
(FURB166
) #18558eq-without-hash
(PLW1641
) #18561unnecessary-round
(RUF057
) #18563check-and-remove-from-set
(FURB132
) #18560nan-comparison
(PLW0177
) #18559pytest-parameter-with-default-argument
(PT028
) #18566pytest-warns-with-multiple-statements
(PT031
) #18569for-loop-writes
(FURB122
) #18565pytest-warns-too-broad
(PT030
) #18568pyupgrade
] Stabilizenon-pep604-annotation-optional
(UP045
) and preview behavior fornon-pep604-annotation-union
(UP007
) #18505flake8-logging
] Stabilizeexc-info-outside-except-handler
(LOG014
) #18517starmap-zip
(RUF058
) #18525pyupgrade
] Stabilizenon-pep695-generic-class
(UP046
) #18519pyupgrade
] Stabilizenon-pep695-generic-function
(UP047
) #18524dataclass-enum
(RUF049
) #18570unnecessary-dict-index-lookup
(PLR1733
) #18571New or improved fixes
Deferred stabilizations
ruff
] StabilizeRUF059
#18481pytest-warns-without-warning
(PT029
) #18567for-loop-set-mutations
(FURB142
) #18557generic-not-last-base-class
(PYI059
) #18601unnecessary-empty-iterable-within-deque-call
(RUF037
) #18564ruff
] Handle extra arguments todeque
(RUF037
) #18614flake8-logging
] Stabilizelog-exception-outside-except-handler
(LOG004
) #18603falsy-dict-get-fallback
(RUF056
) #18562default
and ignores extra arguments #18628 and [ruff
] Validate arguments before offering a fix (RUF056
) #18631pylint
] Stabilizeunnecessary-lambda
(PLW0108
) #18553TODOs
emptyfirst commit (random whitespace change to get a baseline ecosystem check executable)Tests
Ruff invocations on examples to verify that behavior has been stabilized correctly.
Note: Run the above with both
--diff
and--statistics
to see behavior changes for fixes as well as rule stabilizations (and the stabilization of syntax/semantic errors).The below should offer a fix to remove the import:
echo "from __future__ import annotations" | ruff check --no-cache --isolated --diff --stdin-filename ex.pyi --select PYI044 -