---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
literal_membership.py:2:6: PLR6201 [*] Use a `set` literal when testing for membership
  |
1 | # Errors
2 | 1 in [1, 2, 3]
  |      ^^^^^^^^^ PLR6201
3 | 1 in (1, 2, 3)
4 | 1 in (
  |
  = help: Convert to `set`

ℹ Unsafe fix
1 1 | # Errors
2   |-1 in [1, 2, 3]
  2 |+1 in {1, 2, 3}
3 3 | 1 in (1, 2, 3)
4 4 | 1 in (
5 5 |     1, 2, 3

literal_membership.py:3:6: PLR6201 [*] Use a `set` literal when testing for membership
  |
1 | # Errors
2 | 1 in [1, 2, 3]
3 | 1 in (1, 2, 3)
  |      ^^^^^^^^^ PLR6201
4 | 1 in (
5 |     1, 2, 3
  |
  = help: Convert to `set`

ℹ Unsafe fix
1 1 | # Errors
2 2 | 1 in [1, 2, 3]
3   |-1 in (1, 2, 3)
  3 |+1 in {1, 2, 3}
4 4 | 1 in (
5 5 |     1, 2, 3
6 6 | )

literal_membership.py:4:6: PLR6201 [*] Use a `set` literal when testing for membership
  |
2 |   1 in [1, 2, 3]
3 |   1 in (1, 2, 3)
4 |   1 in (
  |  ______^
5 | |     1, 2, 3
6 | | )
  | |_^ PLR6201
7 |   fruits = ["cherry", "grapes"]
8 |   "cherry" in fruits
  |
  = help: Convert to `set`

ℹ Unsafe fix
1 1 | # Errors
2 2 | 1 in [1, 2, 3]
3 3 | 1 in (1, 2, 3)
4   |-1 in (
  4 |+1 in {
5 5 |     1, 2, 3
6   |-)
  6 |+}
7 7 | fruits = ["cherry", "grapes"]
8 8 | "cherry" in fruits
9 9 | _ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")}

literal_membership.py:9:70: PLR6201 [*] Use a `set` literal when testing for membership
   |
 7 | fruits = ["cherry", "grapes"]
 8 | "cherry" in fruits
 9 | _ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")}
   |                                                                      ^^^^^^^^^^ PLR6201
10 | 
11 | # OK
   |
   = help: Convert to `set`

ℹ Unsafe fix
6  6  | )
7  7  | fruits = ["cherry", "grapes"]
8  8  | "cherry" in fruits
9     |-_ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")}
   9  |+_ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in {"a", "b"}}
10 10 | 
11 11 | # OK
12 12 | fruits in [[1, 2, 3], [4, 5, 6]]


