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

ℹ Safe fix
1 1 | # Errors
2 2 | 
3   |-for item in {1}:
  3 |+for item in (1,):
4 4 |     print(f"I can count to {item}!")
5 5 | 
6 6 | for item in {"apples", "lemons", "water"}:  # flags in-line set literals

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

ℹ Safe fix
3 3 | for item in {1}:
4 4 |     print(f"I can count to {item}!")
5 5 | 
6   |-for item in {"apples", "lemons", "water"}:  # flags in-line set literals
  6 |+for item in ("apples", "lemons", "water"):  # flags in-line set literals
7 7 |     print(f"I like {item}.")
8 8 | 
9 9 | for item in {1,}:

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

ℹ Safe fix
6  6  | for item in {"apples", "lemons", "water"}:  # flags in-line set literals
7  7  |     print(f"I like {item}.")
8  8  | 
9     |-for item in {1,}:
   9  |+for item in (1,):
10 10 |     print(f"I can count to {item}!")
11 11 | 
12 12 | for item in {

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

ℹ Safe fix
9  9  | for item in {1,}:
10 10 |     print(f"I can count to {item}!")
11 11 | 
12    |-for item in {
   12 |+for item in (
13 13 |     "apples", "lemons", "water"
14    |-}:  # flags in-line set literals
   14 |+):  # flags in-line set literals
15 15 |     print(f"I like {item}.")
16 16 | 
17 17 | numbers_list = [i for i in {1, 2, 3}]  # flags sets in list comprehensions

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

ℹ Safe fix
14 14 | }:  # flags in-line set literals
15 15 |     print(f"I like {item}.")
16 16 | 
17    |-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 18 | 
19 19 | numbers_set = {i for i in {1, 2, 3}}  # flags sets in set comprehensions
20 20 | 

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

ℹ Safe fix
16 16 | 
17 17 | numbers_list = [i for i in {1, 2, 3}]  # flags sets in list comprehensions
18 18 | 
19    |-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 20 | 
21 21 | numbers_dict = {str(i): i for i in {1, 2, 3}}  # flags sets in dict comprehensions
22 22 | 

iteration_over_set.py:21:36: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
   |
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
   |                                    ^^^^^^^^^ PLC0208
22 | 
23 | numbers_gen = (i for i in {1, 2, 3})  # flags sets in generator expressions
   |
   = help: Convert to `tuple`

ℹ Safe fix
18 18 | 
19 19 | numbers_set = {i for i in {1, 2, 3}}  # flags sets in set comprehensions
20 20 | 
21    |-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 22 | 
23 23 | numbers_gen = (i for i in {1, 2, 3})  # flags sets in generator expressions
24 24 | 

iteration_over_set.py:23:27: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
   |
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
   |                           ^^^^^^^^^ PLC0208
24 | 
25 | # Non-errors
   |
   = help: Convert to `tuple`

ℹ Safe fix
20 20 | 
21 21 | numbers_dict = {str(i): i for i in {1, 2, 3}}  # flags sets in dict comprehensions
22 22 | 
23    |-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 24 | 
25 25 | # Non-errors
26 26 | 


