adamchainz / flake8-comprehensions

❄️ A flake8 plugin to help you write better list/set/dict comprehensions.
MIT License
464 stars 23 forks source link

Feature Request: Detect dictionary comprehensions with constant values #552

Closed tjkuson closed 2 months ago

tjkuson commented 7 months ago

Description

Hi! Thanks for this helpful tool.

I'm working with code that has a lot of

{elt: None for elt in foo}

which is slower and (IMO) harder to read than

dict.fromkeys(foo)

Would there be interest in a rule that checks for dictionary comprehensions with constant values?

This has rule has been accepted by another project and it was suggested to me that I create an issue here too.

adamchainz commented 7 months ago

Yeah, I would like that here too. I don’t have time to work on it right now, but I’d accept a PR adding it.

tjkuson commented 7 months ago

I'll open a PR later today.