---
source: crates/ruff_linter/src/rules/refurb/mod.rs
---
FURB171 [*] Membership test against single-item container
 --> FURB171_0.py:3:4
  |
1 | # Errors.
2 |
3 | if 1 in (1,):
  |    ^^^^^^^^^
4 |     print("Single-element tuple")
  |
help: Convert to equality test
  |
2 |
  - if 1 in (1,):
3 + if 1 == 1:
4 |     print("Single-element tuple")
  |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
 --> FURB171_0.py:6:4
  |
4 |     print("Single-element tuple")
5 |
6 | if 1 in [1]:
  |    ^^^^^^^^
7 |     print("Single-element list")
  |
help: Convert to equality test
  |
5 |
  - if 1 in [1]:
6 + if 1 == 1:
7 |     print("Single-element list")
  |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
  --> FURB171_0.py:9:4
   |
 7 |     print("Single-element list")
 8 |
 9 | if 1 in {1}:
   |    ^^^^^^^^
10 |     print("Single-element set")
   |
help: Convert to equality test
   |
8  |
   - if 1 in {1}:
9  + if 1 == 1:
10 |     print("Single-element set")
   |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
  --> FURB171_0.py:12:4
   |
10 |     print("Single-element set")
11 |
12 | if "a" in "a":
   |    ^^^^^^^^^^
13 |     print("Single-element string")
   |
help: Convert to equality test
   |
11 |
   - if "a" in "a":
12 + if "a" == "a":
13 |     print("Single-element string")
   |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
  --> FURB171_0.py:15:4
   |
13 |     print("Single-element string")
14 |
15 | if 1 not in (1,):
   |    ^^^^^^^^^^^^^
16 |     print("Check `not in` membership test")
   |
help: Convert to inequality test
   |
14 |
   - if 1 not in (1,):
15 + if 1 != 1:
16 |     print("Check `not in` membership test")
   |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
  --> FURB171_0.py:18:8
   |
16 |     print("Check `not in` membership test")
17 |
18 | if not 1 in (1,):
   |        ^^^^^^^^^
19 |     print("Check the negated membership test")
   |
help: Convert to equality test
   |
17 |
   - if not 1 in (1,):
18 + if not 1 == 1:
19 |     print("Check the negated membership test")
   |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
  --> FURB171_0.py:52:5
   |
51 |   # https://github.com/astral-sh/ruff/issues/10063
52 |   _ = a in (
   |  _____^
53 | |     # Foo
54 | |     b,
55 | | )
   | |_^
56 |
57 |   _ = a in (  # Foo1
   |
help: Convert to equality test
   |
51 | # https://github.com/astral-sh/ruff/issues/10063
   - _ = a in (
   -     # Foo
   -     b,
   - )
52 + _ = a == b
53 |
   |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
  --> FURB171_0.py:57:5
   |
55 |   )
56 |
57 |   _ = a in (  # Foo1
   |  _____^
58 | |     (  # Foo2
59 | |     # Foo3
60 | |         (  # Tuple
61 | |             (  # Bar
62 | |        (b
63 | |         # Bar
64 | |         )
65 | |   )
66 | |        # Foo4
67 | |             # Foo5
68 | |      ,
69 | |        )
70 | |         # Foo6
71 | |     )
72 | | )
   | |_^
73 |
74 |   foo = (
   |
help: Convert to equality test
   |
56 |
   - _ = a in (  # Foo1
   -     (  # Foo2
   -     # Foo3
   -         (  # Tuple
   -             (  # Bar
57 + _ = a == (  # Bar
58 |        (b
59 |         # Bar
60 |         )
61 |   )
   -        # Foo4
   -             # Foo5
   -      ,
   -        )
   -         # Foo6
   -     )
   - )
62 |
   |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
  --> FURB171_0.py:77:28
   |
75 |       lorem()
76 |           .ipsum()
77 |           .dolor(lambda sit: sit in (
   |  ____________________________^
78 | |             # Foo1
79 | |             # Foo2
80 | |             amet,
81 | |         ))
   | |_________^
82 |   )
   |
help: Convert to equality test
   |
76 |         .ipsum()
   -         .dolor(lambda sit: sit in (
   -             # Foo1
   -             # Foo2
   -             amet,
   -         ))
77 +         .dolor(lambda sit: sit == amet)
78 | )
   |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
  --> FURB171_0.py:87:28
   |
85 |       lorem()
86 |           .ipsum()
87 |           .dolor(lambda sit: sit in (
   |  ____________________________^
88 | |             (
89 | |                 # Foo1
90 | |                 # Foo2
91 | |                 amet
92 | |             ),
93 | |         ))
   | |_________^
94 |   )
   |
help: Convert to equality test
   |
86 |         .ipsum()
   -         .dolor(lambda sit: sit in (
   -             (
87 +         .dolor(lambda sit: sit == (
88 |                 # Foo1
89 |                 # Foo2
90 |                 amet
   -             ),
   -         ))
91 +             ))
92 | )
   |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
   --> FURB171_0.py:98:24
    |
 96 |   foo = lorem() \
 97 |       .ipsum() \
 98 |       .dolor(lambda sit: sit in (
    |  ________________________^
 99 | |         # Foo1
100 | |         # Foo2
101 | |         amet,
102 | |     ))
    | |_____^
103 |
104 |   def _():
    |
help: Convert to equality test
   |
97 |     .ipsum() \
   -     .dolor(lambda sit: sit in (
   -         # Foo1
   -         # Foo2
   -         amet,
   -     ))
98 +     .dolor(lambda sit: sit == amet)
99 |
   |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
   --> FURB171_0.py:105:8
    |
104 |   def _():
105 |       if foo not \
    |  ________^
106 | |         in [
107 | |         # Before
108 | |         bar
109 | |         # After
110 | |     ]: ...
    | |_____^
111 |
112 |   def _():
    |
help: Convert to inequality test
    |
104 | def _():
    -     if foo not \
    -         in [
    -         # Before
    -         bar
    -         # After
    -     ]: ...
105 +     if foo != bar: ...
106 |
    |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
   --> FURB171_0.py:113:8
    |
112 |   def _():
113 |       if foo not \
    |  ________^
114 | |         in [
115 | |         # Before
116 | |         bar
117 | |         # After
118 | |     ] and \
    | |_____^
119 |           0 < 1: ...
    |
help: Convert to inequality test
    |
112 | def _():
    -     if foo not \
    -         in [
    -         # Before
    -         bar
    -         # After
    -     ] and \
113 +     if foo != bar and \
114 |         0 < 1: ...
    |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
   --> FURB171_0.py:125:4
    |
124 | # NaN behavior differences
125 | if math.nan in [math.nan]:
    |    ^^^^^^^^^^^^^^^^^^^^^^
126 |     print("This is True")
    |
help: Convert to equality test
    |
124 | # NaN behavior differences
    - if math.nan in [math.nan]:
125 + if math.nan == math.nan:
126 |     print("This is True")
    |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
   --> FURB171_0.py:128:4
    |
126 |     print("This is True")
127 |
128 | if math.nan in (math.nan,):
    |    ^^^^^^^^^^^^^^^^^^^^^^^
129 |     print("This is True")
    |
help: Convert to equality test
    |
127 |
    - if math.nan in (math.nan,):
128 + if math.nan == math.nan:
129 |     print("This is True")
    |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
   --> FURB171_0.py:131:4
    |
129 |     print("This is True")
130 |
131 | if math.nan in {math.nan}:
    |    ^^^^^^^^^^^^^^^^^^^^^^
132 |     print("This is True")
    |
help: Convert to equality test
    |
130 |
    - if math.nan in {math.nan}:
131 + if math.nan == math.nan:
132 |     print("This is True")
    |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
   --> FURB171_0.py:140:4
    |
139 | obj = CustomEq()
140 | if obj in [CustomEq()]:
    |    ^^^^^^^^^^^^^^^^^^^
141 |     pass
    |
help: Convert to equality test
    |
139 | obj = CustomEq()
    - if obj in [CustomEq()]:
140 + if obj == CustomEq():
141 |     pass
    |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
   --> FURB171_0.py:143:4
    |
141 |     pass
142 |
143 | if obj in (CustomEq(),):
    |    ^^^^^^^^^^^^^^^^^^^^
144 |     pass
    |
help: Convert to equality test
    |
142 |
    - if obj in (CustomEq(),):
143 + if obj == CustomEq():
144 |     pass
    |
note: This is an unsafe fix and may change runtime behavior

FURB171 [*] Membership test against single-item container
   --> FURB171_0.py:146:4
    |
144 |     pass
145 |
146 | if obj in {CustomEq()}:
    |    ^^^^^^^^^^^^^^^^^^^
147 |     pass
    |
help: Convert to equality test
    |
145 |
    - if obj in {CustomEq()}:
146 + if obj == CustomEq():
147 |     pass
    |
note: This is an unsafe fix and may change runtime behavior
