MartinThoma / flake8-simplify

❄ A flake8 plugin that helps you to simplify code
MIT License
186 stars 19 forks source link

[New Rule] AnySequence(dict.keys()) to AnySequence(dict) #181

Open janosh opened 1 year ago

janosh commented 1 year ago

Would be nice if SIM118 could be expanded (or a new rule created) that not just covers iterating over dict keys but also converting them to any type of iterable:

# bad
list(dict.keys())
tuple(dict.keys())
set(dict.keys())
[*dict.keys()]
{*dict.keys()}

# good
list(dict)
tuple(dict)
set(dict)
[*dict]
{*dict}

Related: https://github.com/charliermarsh/ruff/issues/4262