Skip to content

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Apr 27, 2025

https://docs.astral.sh/ruff/rules/unnecessary-dict-comprehension-for-iterable

Why is this bad?

It's unnecessary to use a dict comprehension to build a dictionary from an iterable when the value is static.

Prefer dict.fromkeys(iterable) over {value: None for value in iterable}, as dict.fromkeys is more readable and efficient.

@cclauss
Copy link
Contributor Author

cclauss commented Apr 27, 2025

Closing as fixed in #2007.

@cclauss cclauss closed this Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant