Skip to content
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

[Ruff 0.5] Stabilise manual-dict-comprehension (PERF403) #12045

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

AlexWaygood
Copy link
Member

Summary

This rule's been in preview for a very long time (over 9 months, if I'm not mistaken). There are no open issues about it, the docs accurately describe what it does, and the implementation seems sound.

It's an opinionated rule that advocates a micro-optimisation -- but this is true for all the perflint rules, and is flagged in the docs. I don't think you'd enable the PERF category at all if you weren't interested in this kind of rule.

@AlexWaygood AlexWaygood added the rule Implementing or modifying a lint rule label Jun 26, 2024
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+6 -0 violations, +0 -0 fixes in 1 projects; 49 projects unchanged)

apache/airflow (+6 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ airflow/providers/cncf/kubernetes/executors/kubernetes_executor_utils.py:149:17: PERF403 Use a dictionary comprehension instead of a for-loop
+ airflow/providers/exasol/hooks/exasol.py:68:17: PERF403 Use a dictionary comprehension instead of a for-loop
+ airflow/providers/mysql/hooks/mysql.py:171:17: PERF403 Use a dictionary comprehension instead of a for-loop
+ airflow/providers/postgres/hooks/postgres.py:173:17: PERF403 Use a dictionary comprehension instead of a for-loop
+ dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2486:13: PERF403 Use a dictionary comprehension instead of a for-loop
+ tests/providers/apache/spark/hooks/test_spark_submit.py:74:17: PERF403 Use a dictionary comprehension instead of a for-loop

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PERF403 6 6 0 0 0

Linter (preview)

✅ ecosystem check detected no linter changes.

@AlexWaygood
Copy link
Member Author

The ecosystem report LGTM. Those indeed could all be replaced with dict comprehensions if you wanted to micro-optimise your code.

Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all ecosystem changes except for the last one would require using dict.update method. This part is documented in the [example section], so seems good to promote to stable.

@AlexWaygood AlexWaygood merged commit 0ef31e2 into ruff-0.5 Jun 26, 2024
20 checks passed
@AlexWaygood AlexWaygood deleted the perflint-stabilisation branch June 26, 2024 12:01
@MichaReiser MichaReiser mentioned this pull request Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants