-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
acceptedReady for implementationReady for implementationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
ruff should error and suggest the following fix when passing a mutable 2nd arg to dict.fromkeys() since modifications will affect all keys which is a common pitfall.
# bad
dict.fromkeys((1, 2), {})
dict.fromkeys((1, 2), [])
dict.fromkeys((1, 2), set())
# ...
# good
{key: {} for key in (1, 2)}
{key: [] for key in (1, 2)}
{key: set() for key in (1, 2)}Examples:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
acceptedReady for implementationReady for implementationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule