flake8-comprehensions
flake8-comprehensions copied to clipboard
Detect `set({})` calls
Description
I have seen this a few times. {...} is a literal set so seems reasonable to warn about set({}) in addition to set([]) and set(()).
Yeah, this could be cool. Since I'm mostly using Ruff now, though, I would rather that we just develop the rule there...
No problem! In the Ruff discussion, we're not sure where to add it. If you were to implement it in flake8-comprehensions, would you add it to an existing rule, or as a new rule?
I don't have a strong opinion, but I lean towards a new rule, mainly because set literal syntax was only added in Python 2.7/3.1. That means set([...]) and set((...)) may come from historical code that wasn't redundant at the time, but set({...}) comes from modern code that was written redundantly.