We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dict.fromkeys(keys, mutable)
Suggest the following fix when passing a mutable 2nd arg to dict.fromkeys() since modifications will affect all keys which is a common pitfall.
dict.fromkeys()
# 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:
Related issue: astral-sh/ruff#4613
The text was updated successfully, but these errors were encountered:
ruff
mutable-fromkeys-value
RUF024
No branches or pull requests
Suggest the following fix when passing a mutable 2nd arg to
dict.fromkeys()
since modifications will affect all keys which is a common pitfall.Examples:
Related issue: astral-sh/ruff#4613
The text was updated successfully, but these errors were encountered: