---
source: crates/ruff_linter/src/rules/refurb/mod.rs
---
FURB171.py:3:4: FURB171 [*] Membership test against single-item container
  |
1 | # Errors.
2 | 
3 | if 1 in (1,):
  |    ^^^^^^^^^ FURB171
4 |     print("Single-element tuple")
  |
  = help: Convert to equality test

ℹ Safe fix
1 1 | # Errors.
2 2 | 
3   |-if 1 in (1,):
  3 |+if 1 == 1:
4 4 |     print("Single-element tuple")
5 5 | 
6 6 | if 1 in [1]:

FURB171.py:6:4: FURB171 [*] Membership test against single-item container
  |
4 |     print("Single-element tuple")
5 | 
6 | if 1 in [1]:
  |    ^^^^^^^^ FURB171
7 |     print("Single-element list")
  |
  = help: Convert to equality test

ℹ Safe fix
3 3 | if 1 in (1,):
4 4 |     print("Single-element tuple")
5 5 | 
6   |-if 1 in [1]:
  6 |+if 1 == 1:
7 7 |     print("Single-element list")
8 8 | 
9 9 | if 1 in {1}:

FURB171.py:9:4: FURB171 [*] Membership test against single-item container
   |
 7 |     print("Single-element list")
 8 | 
 9 | if 1 in {1}:
   |    ^^^^^^^^ FURB171
10 |     print("Single-element set")
   |
   = help: Convert to equality test

ℹ Safe fix
6  6  | if 1 in [1]:
7  7  |     print("Single-element list")
8  8  | 
9     |-if 1 in {1}:
   9  |+if 1 == 1:
10 10 |     print("Single-element set")
11 11 | 
12 12 | if "a" in "a":

FURB171.py:12:4: FURB171 [*] Membership test against single-item container
   |
10 |     print("Single-element set")
11 | 
12 | if "a" in "a":
   |    ^^^^^^^^^^ FURB171
13 |     print("Single-element string")
   |
   = help: Convert to equality test

ℹ Safe fix
9  9  | if 1 in {1}:
10 10 |     print("Single-element set")
11 11 | 
12    |-if "a" in "a":
   12 |+if "a" == "a":
13 13 |     print("Single-element string")
14 14 | 
15 15 | if 1 not in (1,):

FURB171.py:15:4: FURB171 [*] Membership test against single-item container
   |
13 |     print("Single-element string")
14 | 
15 | if 1 not in (1,):
   |    ^^^^^^^^^^^^^ FURB171
16 |     print("Check `not in` membership test")
   |
   = help: Convert to inequality test

ℹ Safe fix
12 12 | if "a" in "a":
13 13 |     print("Single-element string")
14 14 | 
15    |-if 1 not in (1,):
   15 |+if 1 != 1:
16 16 |     print("Check `not in` membership test")
17 17 | 
18 18 | if not 1 in (1,):

FURB171.py:18:8: FURB171 [*] Membership test against single-item container
   |
16 |     print("Check `not in` membership test")
17 | 
18 | if not 1 in (1,):
   |        ^^^^^^^^^ FURB171
19 |     print("Check the negated membership test")
   |
   = help: Convert to equality test

ℹ Safe fix
15 15 | if 1 not in (1,):
16 16 |     print("Check `not in` membership test")
17 17 | 
18    |-if not 1 in (1,):
   18 |+if not 1 == 1:
19 19 |     print("Check the negated membership test")
20 20 | 
21 21 | # Non-errors.


