Consider with statements for too many branches lint#11321
Merged
charliermarsh merged 4 commits intoastral-sh:mainfrom May 8, 2024
Merged
Consider with statements for too many branches lint#11321charliermarsh merged 4 commits intoastral-sh:mainfrom
charliermarsh merged 4 commits intoastral-sh:mainfrom
Conversation
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| PLR0912 | 61 | 45 | 16 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+45 -16 violations, +0 -0 fixes in 3 projects; 41 projects unchanged)
apache/airflow (+29 -6 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
- airflow/cli/commands/connection_command.py:209:5: PLR0912 Too many branches (17 > 12) + airflow/cli/commands/connection_command.py:209:5: PLR0912 Too many branches (19 > 12) - airflow/cli/commands/task_command.py:404:5: PLR0912 Too many branches (15 > 12) + airflow/cli/commands/task_command.py:404:5: PLR0912 Too many branches (16 > 12) - airflow/cli/commands/task_command.py:631:5: PLR0912 Too many branches (16 > 12) + airflow/cli/commands/task_command.py:631:5: PLR0912 Too many branches (18 > 12) + airflow/models/dagrun.py:755:9: PLR0912 Too many branches (15 > 12) + airflow/models/taskinstance.py:2489:9: PLR0912 Too many branches (24 > 12) - airflow/models/taskinstance.py:400:5: PLR0912 Too many branches (14 > 12) + airflow/models/taskinstance.py:400:5: PLR0912 Too many branches (22 > 12) + airflow/providers/apache/hive/transfers/s3_to_hive.py:141:9: PLR0912 Too many branches (17 > 12) + airflow/providers/apache/livy/hooks/livy.py:496:15: PLR0912 Too many branches (16 > 12) + airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py:213:9: PLR0912 Too many branches (16 > 12) + airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py:379:9: PLR0912 Too many branches (17 > 12) + airflow/providers/common/sql/hooks/sql.py:356:9: PLR0912 Too many branches (14 > 12) + airflow/providers/databricks/hooks/databricks_sql.py:199:9: PLR0912 Too many branches (16 > 12) + airflow/providers/databricks/operators/databricks_sql.py:126:9: PLR0912 Too many branches (13 > 12) + airflow/providers/elasticsearch/log/es_task_handler.py:216:9: PLR0912 Too many branches (14 > 12) + airflow/providers/exasol/hooks/exasol.py:187:9: PLR0912 Too many branches (14 > 12) + airflow/providers/google/cloud/operators/gcs.py:792:9: PLR0912 Too many branches (20 > 12) + airflow/providers/http/hooks/http.py:318:15: PLR0912 Too many branches (24 > 12) + airflow/providers/openlineage/utils/utils.py:305:9: PLR0912 Too many branches (13 > 12) + airflow/providers/snowflake/hooks/snowflake.py:340:9: PLR0912 Too many branches (14 > 12) + airflow/utils/db.py:1554:5: PLR0912 Too many branches (16 > 12) + airflow/www/views.py:3424:9: PLR0912 Too many branches (13 > 12) + airflow/www/views.py:739:9: PLR0912 Too many branches (36 > 12) + dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2021:5: PLR0912 Too many branches (23 > 12) + dev/breeze/src/airflow_breeze/commands/release_management_commands.py:3277:5: PLR0912 Too many branches (19 > 12) ... 7 additional changes omitted for project
bokeh/bokeh (+2 -2 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
- src/bokeh/command/subcommands/serve.py:802:9: PLR0912 Too many branches (25 > 12) + src/bokeh/command/subcommands/serve.py:802:9: PLR0912 Too many branches (31 > 12) - src/bokeh/embed/bundle.py:259:5: PLR0912 Too many branches (15 > 12) + src/bokeh/embed/bundle.py:259:5: PLR0912 Too many branches (17 > 12)
zulip/zulip (+14 -8 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ corporate/lib/stripe.py:1700:9: PLR0912 Too many branches (19 > 12) - corporate/lib/stripe.py:2770:9: PLR0912 Too many branches (27 > 12) + corporate/lib/stripe.py:2770:9: PLR0912 Too many branches (28 > 12) - zerver/actions/create_realm.py:155:5: PLR0912 Too many branches (19 > 12) + zerver/actions/create_realm.py:155:5: PLR0912 Too many branches (22 > 12) - zerver/actions/message_send.py:846:5: PLR0912 Too many branches (29 > 12) + zerver/actions/message_send.py:846:5: PLR0912 Too many branches (34 > 12) + zerver/actions/scheduled_messages.py:129:5: PLR0912 Too many branches (18 > 12) - zerver/lib/import_realm.py:775:5: PLR0912 Too many branches (32 > 12) + zerver/lib/import_realm.py:775:5: PLR0912 Too many branches (33 > 12) - zerver/lib/import_realm.py:966:5: PLR0912 Too many branches (38 > 12) + zerver/lib/import_realm.py:966:5: PLR0912 Too many branches (48 > 12) + zerver/lib/push_notifications.py:1267:5: PLR0912 Too many branches (17 > 12) - zerver/management/commands/export_search.py:101:9: PLR0912 Too many branches (17 > 12) + zerver/management/commands/export_search.py:101:9: PLR0912 Too many branches (18 > 12) + zerver/views/message_fetch.py:99:5: PLR0912 Too many branches (22 > 12) + zerver/views/streams.py:699:5: PLR0912 Too many branches (14 > 12) + zerver/worker/base.py:166:9: PLR0912 Too many branches (14 > 12) ... 4 additional changes omitted for project
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| PLR0912 | 61 | 45 | 16 | 0 | 0 |
dhruvmanila
requested changes
May 7, 2024
Member
There was a problem hiding this comment.
Can you include additional test cases in this file for with statements? They will be at the bottom of this file and they specifically tests the num_branches function.
dhruvmanila
approved these changes
May 7, 2024
Member
|
Thank you for working on this! Welcome to Ruff :) |
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
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.
Resolves #11313
Summary
PLR0912(too-many-branches) did not count branches inside with: blocks. With this fix, the branches inside with statements are also counted.
Test Plan
Added a new test case.