---
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs
---
B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:11:5
   |
 9 |     "str"  # Str (no raise)
10 |     f"{int}"  # JoinedStr (no raise)
11 |     1j  # Number (complex)
   |     ^^
12 |     1  # Number (int)
13 |     1.0  # Number (float)
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:12:5
   |
10 |     f"{int}"  # JoinedStr (no raise)
11 |     1j  # Number (complex)
12 |     1  # Number (int)
   |     ^
13 |     1.0  # Number (float)
14 |     b"foo"  # Binary
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:13:5
   |
11 |     1j  # Number (complex)
12 |     1  # Number (int)
13 |     1.0  # Number (float)
   |     ^^^
14 |     b"foo"  # Binary
15 |     True  # NameConstant (True)
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:14:5
   |
12 |     1  # Number (int)
13 |     1.0  # Number (float)
14 |     b"foo"  # Binary
   |     ^^^^^^
15 |     True  # NameConstant (True)
16 |     False  # NameConstant (False)
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:15:5
   |
13 |     1.0  # Number (float)
14 |     b"foo"  # Binary
15 |     True  # NameConstant (True)
   |     ^^^^
16 |     False  # NameConstant (False)
17 |     None  # NameConstant (None)
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:16:5
   |
14 |     b"foo"  # Binary
15 |     True  # NameConstant (True)
16 |     False  # NameConstant (False)
   |     ^^^^^
17 |     None  # NameConstant (None)
18 |     [1, 2]  # list
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:17:5
   |
15 |     True  # NameConstant (True)
16 |     False  # NameConstant (False)
17 |     None  # NameConstant (None)
   |     ^^^^
18 |     [1, 2]  # list
19 |     {1, 2}  # set
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:18:5
   |
16 |     False  # NameConstant (False)
17 |     None  # NameConstant (None)
18 |     [1, 2]  # list
   |     ^^^^^^
19 |     {1, 2}  # set
20 |     {"foo": "bar"}  # dict
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:19:5
   |
17 |     None  # NameConstant (None)
18 |     [1, 2]  # list
19 |     {1, 2}  # set
   |     ^^^^^^
20 |     {"foo": "bar"}  # dict
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:20:5
   |
18 |     [1, 2]  # list
19 |     {1, 2}  # set
20 |     {"foo": "bar"}  # dict
   |     ^^^^^^^^^^^^^^
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:24:5
   |
23 | class Foo3:
24 |     123
   |     ^^^
25 |     a = 2
26 |     "str"
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:27:5
   |
25 |     a = 2
26 |     "str"
27 |     1
   |     ^
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:39:5
   |
37 |     "str"  # Str (no raise)
38 |     f"{int}"  # JoinedStr (no raise)
39 |     1j  # Number (complex)
   |     ^^
40 |     1  # Number (int)
41 |     1.0  # Number (float)
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:40:5
   |
38 |     f"{int}"  # JoinedStr (no raise)
39 |     1j  # Number (complex)
40 |     1  # Number (int)
   |     ^
41 |     1.0  # Number (float)
42 |     b"foo"  # Binary
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:41:5
   |
39 |     1j  # Number (complex)
40 |     1  # Number (int)
41 |     1.0  # Number (float)
   |     ^^^
42 |     b"foo"  # Binary
43 |     True  # NameConstant (True)
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:42:5
   |
40 |     1  # Number (int)
41 |     1.0  # Number (float)
42 |     b"foo"  # Binary
   |     ^^^^^^
43 |     True  # NameConstant (True)
44 |     False  # NameConstant (False)
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:43:5
   |
41 |     1.0  # Number (float)
42 |     b"foo"  # Binary
43 |     True  # NameConstant (True)
   |     ^^^^
44 |     False  # NameConstant (False)
45 |     None  # NameConstant (None)
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:44:5
   |
42 |     b"foo"  # Binary
43 |     True  # NameConstant (True)
44 |     False  # NameConstant (False)
   |     ^^^^^
45 |     None  # NameConstant (None)
46 |     [1, 2]  # list
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:45:5
   |
43 |     True  # NameConstant (True)
44 |     False  # NameConstant (False)
45 |     None  # NameConstant (None)
   |     ^^^^
46 |     [1, 2]  # list
47 |     {1, 2}  # set
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:46:5
   |
44 |     False  # NameConstant (False)
45 |     None  # NameConstant (None)
46 |     [1, 2]  # list
   |     ^^^^^^
47 |     {1, 2}  # set
48 |     {"foo": "bar"}  # dict
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:47:5
   |
45 |     None  # NameConstant (None)
46 |     [1, 2]  # list
47 |     {1, 2}  # set
   |     ^^^^^^
48 |     {"foo": "bar"}  # dict
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:48:5
   |
46 |     [1, 2]  # list
47 |     {1, 2}  # set
48 |     {"foo": "bar"}  # dict
   |     ^^^^^^^^^^^^^^
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:52:5
   |
51 | def foo3():
52 |     123
   |     ^^^
53 |     a = 2
54 |     "str"
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:55:5
   |
53 |     a = 2
54 |     "str"
55 |     3
   |     ^
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:63:5
   |
62 | def foo5():
63 |     foo.bar  # Attribute (raise)
   |     ^^^^^^^
64 |     object().__class__  # Attribute (raise)
65 |     "foo" + "bar"  # BinOp (raise)
   |

B018 Found useless attribute access. Either assign it to a variable or remove it.
  --> B018.py:64:5
   |
62 | def foo5():
63 |     foo.bar  # Attribute (raise)
64 |     object().__class__  # Attribute (raise)
   |     ^^^^^^^^^^^^^^^^^^
65 |     "foo" + "bar"  # BinOp (raise)
   |

B018 Found useless expression. Either assign it to a variable or remove it.
  --> B018.py:65:5
   |
63 |     foo.bar  # Attribute (raise)
64 |     object().__class__  # Attribute (raise)
65 |     "foo" + "bar"  # BinOp (raise)
   |     ^^^^^^^^^^^^^
   |
