Skip to content

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

@janosh

Description

@janosh

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: astral-sh/ruff#4262

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions