---
source: crates/ruff_linter/src/rules/ruff/mod.rs
---
RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys`
  --> RUF024.py:9:1
   |
 8 | # Errors.
 9 | dict.fromkeys(pierogi_fillings, [])
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 | dict.fromkeys(pierogi_fillings, list())
11 | dict.fromkeys(pierogi_fillings, {})
   |
help: Replace with comprehension
   |
8  | # Errors.
   - dict.fromkeys(pierogi_fillings, [])
9  + {key: [] for key in pierogi_fillings}
10 | dict.fromkeys(pierogi_fillings, list())
   |
note: This is an unsafe fix and may change runtime behavior

RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys`
  --> RUF024.py:10:1
   |
 8 | # Errors.
 9 | dict.fromkeys(pierogi_fillings, [])
10 | dict.fromkeys(pierogi_fillings, list())
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 | dict.fromkeys(pierogi_fillings, {})
12 | dict.fromkeys(pierogi_fillings, set())
   |
help: Replace with comprehension
   |
9  | dict.fromkeys(pierogi_fillings, [])
   - dict.fromkeys(pierogi_fillings, list())
10 + {key: list() for key in pierogi_fillings}
11 | dict.fromkeys(pierogi_fillings, {})
   |
note: This is an unsafe fix and may change runtime behavior

RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys`
  --> RUF024.py:11:1
   |
 9 | dict.fromkeys(pierogi_fillings, [])
10 | dict.fromkeys(pierogi_fillings, list())
11 | dict.fromkeys(pierogi_fillings, {})
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 | dict.fromkeys(pierogi_fillings, set())
13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"})
   |
help: Replace with comprehension
   |
10 | dict.fromkeys(pierogi_fillings, list())
   - dict.fromkeys(pierogi_fillings, {})
11 + {key: {} for key in pierogi_fillings}
12 | dict.fromkeys(pierogi_fillings, set())
   |
note: This is an unsafe fix and may change runtime behavior

RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys`
  --> RUF024.py:12:1
   |
10 | dict.fromkeys(pierogi_fillings, list())
11 | dict.fromkeys(pierogi_fillings, {})
12 | dict.fromkeys(pierogi_fillings, set())
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"})
14 | dict.fromkeys(pierogi_fillings, dict())
   |
help: Replace with comprehension
   |
11 | dict.fromkeys(pierogi_fillings, {})
   - dict.fromkeys(pierogi_fillings, set())
12 + {key: set() for key in pierogi_fillings}
13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"})
   |
note: This is an unsafe fix and may change runtime behavior

RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys`
  --> RUF024.py:13:1
   |
11 | dict.fromkeys(pierogi_fillings, {})
12 | dict.fromkeys(pierogi_fillings, set())
13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"})
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14 | dict.fromkeys(pierogi_fillings, dict())
15 | import builtins
   |
help: Replace with comprehension
   |
12 | dict.fromkeys(pierogi_fillings, set())
   - dict.fromkeys(pierogi_fillings, {"pre": "populated!"})
13 + {key: {"pre": "populated!"} for key in pierogi_fillings}
14 | dict.fromkeys(pierogi_fillings, dict())
   |
note: This is an unsafe fix and may change runtime behavior

RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys`
  --> RUF024.py:14:1
   |
12 | dict.fromkeys(pierogi_fillings, set())
13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"})
14 | dict.fromkeys(pierogi_fillings, dict())
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 | import builtins
16 | builtins.dict.fromkeys(pierogi_fillings, dict())
   |
help: Replace with comprehension
   |
13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"})
   - dict.fromkeys(pierogi_fillings, dict())
14 + {key: dict() for key in pierogi_fillings}
15 | import builtins
   |
note: This is an unsafe fix and may change runtime behavior

RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys`
  --> RUF024.py:16:1
   |
14 | dict.fromkeys(pierogi_fillings, dict())
15 | import builtins
16 | builtins.dict.fromkeys(pierogi_fillings, dict())
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17 |
18 | # Okay.
   |
help: Replace with comprehension
   |
15 | import builtins
   - builtins.dict.fromkeys(pierogi_fillings, dict())
16 + {key: dict() for key in pierogi_fillings}
17 |
   |
note: This is an unsafe fix and may change runtime behavior

RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys`
  --> RUF024.py:39:1
   |
37 | key = "xy"
38 | key_0 = "z"
39 | dict.fromkeys("ABC", list(key))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Replace with comprehension
   |
38 | key_0 = "z"
   - dict.fromkeys("ABC", list(key))
39 + {key_1: list(key) for key_1 in "ABC"}
   |
note: This is an unsafe fix and may change runtime behavior
