-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve error messages and docs for flake8-comprehensions
rules
#14729
Merged
Conversation
This file contains 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
AlexWaygood
force-pushed
the
alex/comp-docs
branch
from
December 2, 2024 13:27
b73ddb7
to
a7f42c8
Compare
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
C408 | 6062 | 3031 | 3031 | 0 | 0 |
C416 | 126 | 63 | 63 | 0 | 0 |
C403 | 60 | 30 | 30 | 0 | 0 |
C401 | 58 | 29 | 29 | 0 | 0 |
C417 | 40 | 20 | 20 | 0 | 0 |
C400 | 36 | 18 | 18 | 0 | 0 |
C414 | 30 | 15 | 15 | 0 | 0 |
C409 | 30 | 15 | 15 | 0 | 0 |
C413 | 12 | 6 | 6 | 0 | 0 |
C418 | 12 | 6 | 6 | 0 | 0 |
C405 | 4 | 2 | 2 | 0 | 0 |
C402 | 4 | 2 | 2 | 0 | 0 |
C406 | 4 | 2 | 2 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+3239 -3239 violations, +0 -0 fixes in 6 projects; 49 projects unchanged)
apache/airflow (+928 -928 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ airflow/api_connexion/endpoints/dag_stats_endpoint.py:58:21: C414 Unnecessary `list()` call within `sorted()` - airflow/api_connexion/endpoints/dag_stats_endpoint.py:58:21: C414 Unnecessary `list` call within `sorted()` - airflow/api_fastapi/core_api/routes/public/dags.py:139:42: C416 Unnecessary `list` comprehension (rewrite using `list()`) + airflow/api_fastapi/core_api/routes/public/dags.py:139:42: C416 Unnecessary list comprehension (rewrite using `list()`) - airflow/api_fastapi/core_api/routes/ui/config.py:69:19: C416 Unnecessary `dict` comprehension (rewrite using `dict()`) + airflow/api_fastapi/core_api/routes/ui/config.py:69:19: C416 Unnecessary dict comprehension (rewrite using `dict()`) + airflow/cli/commands/backfill_command.py:65:20: C408 Unnecessary `dict()` call (rewrite as a literal) - airflow/cli/commands/backfill_command.py:65:20: C408 Unnecessary `dict` call (rewrite as a literal) + airflow/cli/commands/variable_command.py:113:47: C413 [*] Unnecessary `list()` call around `sorted()` - airflow/cli/commands/variable_command.py:113:47: C413 [*] Unnecessary `list` call around `sorted()` - airflow/dag_processing/collection.py:481:34: C416 Unnecessary `list` comprehension (rewrite using `list()`) + airflow/dag_processing/collection.py:481:34: C416 Unnecessary list comprehension (rewrite using `list()`) ... 31 additional changes omitted for rule C416 - airflow/dag_processing/manager.py:1370:26: C400 Unnecessary generator (rewrite as a `list` comprehension) + airflow/dag_processing/manager.py:1370:26: C400 Unnecessary generator (rewrite as a list comprehension) ... 1842 additional changes omitted for project
apache/superset (+95 -95 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ superset/advanced_data_type/plugins/internet_address.py:68:17: C417 Unnecessary `map()` usage (rewrite using a generator expression) - superset/advanced_data_type/plugins/internet_address.py:68:17: C417 Unnecessary `map` usage (rewrite using a generator expression) + superset/advanced_data_type/plugins/internet_port.py:97:17: C417 Unnecessary `map()` usage (rewrite using a generator expression) - superset/advanced_data_type/plugins/internet_port.py:97:17: C417 Unnecessary `map` usage (rewrite using a generator expression) - superset/charts/post_processing.py:175:33: C409 Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) + superset/charts/post_processing.py:175:33: C409 Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) - superset/charts/post_processing.py:192:33: C409 Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) + superset/charts/post_processing.py:192:33: C409 Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + superset/commands/exceptions.py:74:16: C413 [*] Unnecessary `list()` call around `sorted()` - superset/commands/exceptions.py:74:16: C413 [*] Unnecessary `list` call around `sorted()` ... 180 additional changes omitted for project
bokeh/bokeh (+948 -948 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ docs/bokeh/source/docs/first_steps/examples/first_steps_8_filter.py:6:32: C408 Unnecessary `dict()` call (rewrite as a literal) - docs/bokeh/source/docs/first_steps/examples/first_steps_8_filter.py:6:32: C408 Unnecessary `dict` call (rewrite as a literal) + examples/advanced/extensions/parallel_plot/parallel_plot.py:29:36: C408 Unnecessary `dict()` call (rewrite as a literal) - examples/advanced/extensions/parallel_plot/parallel_plot.py:29:36: C408 Unnecessary `dict` call (rewrite as a literal) + examples/advanced/extensions/parallel_plot/parallel_plot.py:72:31: C408 Unnecessary `dict()` call (rewrite as a literal) - examples/advanced/extensions/parallel_plot/parallel_plot.py:72:31: C408 Unnecessary `dict` call (rewrite as a literal) ... 1857 additional changes omitted for rule C408 + examples/basic/annotations/whisker.py:17:11: C413 [*] Unnecessary `list()` call around `sorted()` - examples/basic/annotations/whisker.py:17:11: C413 [*] Unnecessary `list` call around `sorted()` - examples/output/webgl/clustering.py:24:19: C416 Unnecessary `list` comprehension (rewrite using `list()`) + examples/output/webgl/clustering.py:24:19: C416 Unnecessary list comprehension (rewrite using `list()`) - examples/plotting/filtering.py:47:30: C416 Unnecessary `list` comprehension (rewrite using `list()`) + examples/plotting/filtering.py:47:30: C416 Unnecessary list comprehension (rewrite using `list()`) - examples/topics/pie/burtin.py:25:8: C406 Unnecessary `list` literal (rewrite as a `dict` literal) + examples/topics/pie/burtin.py:25:8: C406 Unnecessary list literal (rewrite as a dict literal) ... 1882 additional changes omitted for project
latchbio/latch (+11 -11 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
- src/latch/account.py:274:25: C409 Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) + src/latch/account.py:274:25: C409 Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) - src/latch/account.py:312:25: C409 Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) + src/latch/account.py:312:25: C409 Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) - src/latch/ldata/_transfer/progress.py:48:29: C416 Unnecessary `set` comprehension (rewrite using `set()`) + src/latch/ldata/_transfer/progress.py:48:29: C416 Unnecessary set comprehension (rewrite using `set()`) - src/latch/registry/project.py:245:25: C409 Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) + src/latch/registry/project.py:245:25: C409 Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) ... 9 additional changes omitted for rule C409 - src/latch/registry/table.py:637:27: C400 Unnecessary generator (rewrite as a `list` comprehension) + src/latch/registry/table.py:637:27: C400 Unnecessary generator (rewrite as a list comprehension) ... 12 additional changes omitted for project
milvus-io/pymilvus (+24 -24 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
- examples/bulk_import/example_bulkwriter.py:101:33: C416 Unnecessary `list` comprehension (rewrite using `list()`) + examples/bulk_import/example_bulkwriter.py:101:33: C416 Unnecessary list comprehension (rewrite using `list()`) - examples/bulk_import/example_bulkwriter.py:314:30: C416 Unnecessary `list` comprehension (rewrite using `list()`) + examples/bulk_import/example_bulkwriter.py:314:30: C416 Unnecessary list comprehension (rewrite using `list()`) - examples/bulk_import/example_bulkwriter.py:341:39: C416 Unnecessary `list` comprehension (rewrite using `list()`) + examples/bulk_import/example_bulkwriter.py:341:39: C416 Unnecessary list comprehension (rewrite using `list()`) - examples/concurrency/multithreading_hello_milvus.py:42:23: C416 Unnecessary `list` comprehension (rewrite using `list()`) + examples/concurrency/multithreading_hello_milvus.py:42:23: C416 Unnecessary list comprehension (rewrite using `list()`) - examples/concurrency/multithreading_hello_milvus.py:53:13: C416 Unnecessary `list` comprehension (rewrite using `list()`) + examples/concurrency/multithreading_hello_milvus.py:53:13: C416 Unnecessary list comprehension (rewrite using `list()`) ... 38 additional changes omitted for project
zulip/zulip (+1233 -1233 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ analytics/migrations/0015_clear_duplicate_counts.py:23:20: C408 Unnecessary `dict()` call (rewrite as a literal) - analytics/migrations/0015_clear_duplicate_counts.py:23:20: C408 Unnecessary `dict` call (rewrite as a literal) + analytics/views/stats.py:83:19: C408 Unnecessary `dict()` call (rewrite as a literal) - analytics/views/stats.py:83:19: C408 Unnecessary `dict` call (rewrite as a literal) + analytics/views/stats.py:94:17: C408 Unnecessary `dict()` call (rewrite as a literal) - analytics/views/stats.py:94:17: C408 Unnecessary `dict` call (rewrite as a literal) + corporate/lib/activity.py:122:45: C408 Unnecessary `dict()` call (rewrite as a literal) - corporate/lib/activity.py:122:45: C408 Unnecessary `dict` call (rewrite as a literal) + corporate/lib/activity.py:129:46: C408 Unnecessary `dict()` call (rewrite as a literal) - corporate/lib/activity.py:129:46: C408 Unnecessary `dict` call (rewrite as a literal) + corporate/lib/activity.py:136:43: C408 Unnecessary `dict()` call (rewrite as a literal) - corporate/lib/activity.py:136:43: C408 Unnecessary `dict` call (rewrite as a literal) + corporate/lib/activity.py:163:57: C408 Unnecessary `dict()` call (rewrite as a literal) - corporate/lib/activity.py:163:57: C408 Unnecessary `dict` call (rewrite as a literal) + corporate/lib/activity.py:59:20: C408 Unnecessary `dict()` call (rewrite as a literal) - corporate/lib/activity.py:59:20: C408 Unnecessary `dict` call (rewrite as a literal) + corporate/lib/activity.py:63:12: C408 Unnecessary `dict()` call (rewrite as a literal) - corporate/lib/activity.py:63:12: C408 Unnecessary `dict` call (rewrite as a literal) + corporate/lib/activity.py:69:9: C408 Unnecessary `dict()` call (rewrite as a literal) ... 2447 additional changes omitted for project
Changes by rule (13 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
C408 | 6062 | 3031 | 3031 | 0 | 0 |
C416 | 126 | 63 | 63 | 0 | 0 |
C403 | 60 | 30 | 30 | 0 | 0 |
C401 | 58 | 29 | 29 | 0 | 0 |
C417 | 40 | 20 | 20 | 0 | 0 |
C400 | 36 | 18 | 18 | 0 | 0 |
C414 | 30 | 15 | 15 | 0 | 0 |
C409 | 30 | 15 | 15 | 0 | 0 |
C413 | 12 | 6 | 6 | 0 | 0 |
C418 | 12 | 6 | 6 | 0 | 0 |
C405 | 4 | 2 | 2 | 0 | 0 |
C402 | 4 | 2 | 2 | 0 | 0 |
C406 | 4 | 2 | 2 | 0 | 0 |
No changes in the errors being emitted in the ecosystem check, only in the error messages |
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
This PR attempts to improve the docs and error messages for our
flake8-comprehension
rules. Along the way I saw various opportunities for cleanups and micro-optimisations, but the only significant changes should be to the error messages and docs.The main change is to remove quite a few backticks which don't seem necessary and, I think, contributed to some of the confusion in #14644. For example, rather than referring to "
set
comprehensions", refer to "set comprehensions". This reads more naturally, and it's harder to misunderstand it as saying "use a call toset()
", which is how it was misread by the OP in #14644.Test Plan
cargo test -p ruff_linter --lib