---
source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs
---
SIM911 [*] Use `d.items()` instead of `zip(d.keys(), d.values())`
 --> SIM911.py:2:17
  |
1 | def foo(d: dict[str, str]) -> None:
2 |     for k, v in zip(d.keys(), d.values()):  # SIM911
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
3 |         ...
  |
help: Replace `zip(d.keys(), d.values())` with `d.items()`
  |
1 | def foo(d: dict[str, str]) -> None:
  -     for k, v in zip(d.keys(), d.values()):  # SIM911
2 +     for k, v in d.items():  # SIM911
3 |         ...
  |

SIM911 [*] Use `d.items()` instead of `zip(d.keys(), d.values(), strict=True)`
 --> SIM911.py:5:17
  |
3 |         ...
4 |
5 |     for k, v in zip(d.keys(), d.values(), strict=True):  # SIM911
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 |         ...
  |
help: Replace `zip(d.keys(), d.values(), strict=True)` with `d.items()`
  |
4 |
  -     for k, v in zip(d.keys(), d.values(), strict=True):  # SIM911
5 +     for k, v in d.items():  # SIM911
6 |         ...
  |

SIM911 [*] Use `d2.items()` instead of `zip(d2.keys(), d2.values())`
  --> SIM911.py:20:13
   |
18 |     ...
19 |
20 | for k, v in zip(d2.keys(), d2.values()):  # SIM911
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 |     ...
   |
help: Replace `zip(d2.keys(), d2.values())` with `d2.items()`
   |
19 |
   - for k, v in zip(d2.keys(), d2.values()):  # SIM911
20 + for k, v in d2.items():  # SIM911
21 |     ...
   |

SIM911 [*] Use `dict.items()` instead of `zip(dict.keys(), dict.values())`
  --> SIM911.py:30:27
   |
28 | def foo():
29 |     dict = {}
30 |     for country, stars in zip(dict.keys(), dict.values()):
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31 |         ...
   |
help: Replace `zip(dict.keys(), dict.values())` with `dict.items()`
   |
29 |     dict = {}
   -     for country, stars in zip(dict.keys(), dict.values()):
30 +     for country, stars in dict.items():
31 |         ...
   |

SIM911 [*] Use ` flag_stars.items()` instead of `(zip)(flag_stars.keys(), flag_stars.values())`
  --> SIM911.py:36:22
   |
34 | # https://github.com/astral-sh/ruff/issues/18776
35 | flag_stars = {}
36 | for country, stars in(zip)(flag_stars.keys(), flag_stars.values()):...
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37 |
38 | # Regression test for https://github.com/astral-sh/ruff/issues/18778
   |
help: Replace `(zip)(flag_stars.keys(), flag_stars.values())` with ` flag_stars.items()`
   |
35 | flag_stars = {}
   - for country, stars in(zip)(flag_stars.keys(), flag_stars.values()):...
36 + for country, stars in flag_stars.items():...
37 |
   |

SIM911 [*] Use `dict.items()` instead of `zip(dict.keys(), dict.values())`
  --> SIM911.py:45:23
   |
43 |   flag_stars = {"USA": 50, "Slovenia": 3, "Panama": 2, "Australia": 6}
44 |
45 |   for country, stars in zip(
   |  _______________________^
46 | |         flag_stars.keys(),
47 | |         # text
48 | |         flag_stars.values(),
49 | | ):
   | |_^
50 |       print(f"{country}'s flag has {stars} stars.")
   |
help: Replace `zip(dict.keys(), dict.values())` with `dict.items()`
   |
44 |
   - for country, stars in zip(
   -         flag_stars.keys(),
   -         # text
   -         flag_stars.values(),
   - ):
45 + for country, stars in flag_stars.items():
46 |     print(f"{country}'s flag has {stars} stars.")
   |
note: This is an unsafe fix and may change runtime behavior
