---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
 --> iteration_over_set.py:3:13
  |
1 | # Errors
2 |
3 | for item in {1}:
  |             ^^^
4 |     print(f"I can count to {item}!")
  |
help: Convert to `tuple`
  |
2 |
  - for item in {1}:
3 + for item in (1,):
4 |     print(f"I can count to {item}!")
  |

PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
 --> iteration_over_set.py:6:13
  |
4 |     print(f"I can count to {item}!")
5 |
6 | for item in {"apples", "lemons", "water"}:  # flags in-line set literals
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 |     print(f"I like {item}.")
  |
help: Convert to `tuple`
  |
5 |
  - for item in {"apples", "lemons", "water"}:  # flags in-line set literals
6 + for item in ("apples", "lemons", "water"):  # flags in-line set literals
7 |     print(f"I like {item}.")
  |

PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
  --> iteration_over_set.py:9:13
   |
 7 |     print(f"I like {item}.")
 8 |
 9 | for item in {1,}:
   |             ^^^^
10 |     print(f"I can count to {item}!")
   |
help: Convert to `tuple`
   |
8  |
   - for item in {1,}:
9  + for item in (1,):
10 |     print(f"I can count to {item}!")
   |

PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
  --> iteration_over_set.py:12:13
   |
10 |       print(f"I can count to {item}!")
11 |
12 |   for item in {
   |  _____________^
13 | |     "apples", "lemons", "water"
14 | | }:  # flags in-line set literals
   | |_^
15 |       print(f"I like {item}.")
   |
help: Convert to `tuple`
   |
11 |
   - for item in {
12 + for item in (
13 |     "apples", "lemons", "water"
   - }:  # flags in-line set literals
14 + ):  # flags in-line set literals
15 |     print(f"I like {item}.")
   |

PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
  --> iteration_over_set.py:17:28
   |
15 |     print(f"I like {item}.")
16 |
17 | numbers_list = [i for i in {1, 2, 3}]  # flags sets in list comprehensions
   |                            ^^^^^^^^^
18 |
19 | numbers_set = {i for i in {1, 2, 3}}  # flags sets in set comprehensions
   |
help: Convert to `tuple`
   |
16 |
   - numbers_list = [i for i in {1, 2, 3}]  # flags sets in list comprehensions
17 + numbers_list = [i for i in (1, 2, 3)]  # flags sets in list comprehensions
18 |
   |

PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
  --> iteration_over_set.py:19:27
   |
17 | numbers_list = [i for i in {1, 2, 3}]  # flags sets in list comprehensions
18 |
19 | numbers_set = {i for i in {1, 2, 3}}  # flags sets in set comprehensions
   |                           ^^^^^^^^^
20 |
21 | numbers_dict = {str(i): i for i in {1, 2, 3}}  # flags sets in dict comprehensions
   |
help: Convert to `tuple`
   |
18 |
   - numbers_set = {i for i in {1, 2, 3}}  # flags sets in set comprehensions
19 + numbers_set = {i for i in (1, 2, 3)}  # flags sets in set comprehensions
20 |
   |

PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
  --> iteration_over_set.py:21:36
   |
19 | numbers_set = {i for i in {1, 2, 3}}  # flags sets in set comprehensions
20 |
21 | numbers_dict = {str(i): i for i in {1, 2, 3}}  # flags sets in dict comprehensions
   |                                    ^^^^^^^^^
22 |
23 | numbers_gen = (i for i in {1, 2, 3})  # flags sets in generator expressions
   |
help: Convert to `tuple`
   |
20 |
   - numbers_dict = {str(i): i for i in {1, 2, 3}}  # flags sets in dict comprehensions
21 + numbers_dict = {str(i): i for i in (1, 2, 3)}  # flags sets in dict comprehensions
22 |
   |

PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
  --> iteration_over_set.py:23:27
   |
21 | numbers_dict = {str(i): i for i in {1, 2, 3}}  # flags sets in dict comprehensions
22 |
23 | numbers_gen = (i for i in {1, 2, 3})  # flags sets in generator expressions
   |                           ^^^^^^^^^
24 |
25 | # Non-errors
   |
help: Convert to `tuple`
   |
22 |
   - numbers_gen = (i for i in {1, 2, 3})  # flags sets in generator expressions
23 + numbers_gen = (i for i in (1, 2, 3))  # flags sets in generator expressions
24 |
   |
