---
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs
---
B006 [*] Do not use mutable data structures for argument defaults
 --> B006_9.py:1:10
  |
1 | def f1(x=([],)):
  |          ^^^^^
2 |     print(x)
  |
help: Replace with `None`; initialize within function
  |
  - def f1(x=([],)):
1 + def f1(x=None):
2 +     if x is None:
3 +         x = ([],)
4 |     print(x)
  |
note: This is an unsafe fix and may change runtime behavior

B006 [*] Do not use mutable data structures for argument defaults
 --> B006_9.py:5:10
  |
5 | def f2(x=(x for x in "x")):
  |          ^^^^^^^^^^^^^^^^
6 |     print(x)
  |
help: Replace with `None`; initialize within function
  |
4 |
  - def f2(x=(x for x in "x")):
5 + def f2(x=None):
6 +     if x is None:
7 +         x = (x for x in "x")
8 |     print(x)
  |
note: This is an unsafe fix and may change runtime behavior

B006 [*] Do not use mutable data structures for argument defaults
  --> B006_9.py:9:10
   |
 9 | def f3(x=((x for x in "x"),)):
   |          ^^^^^^^^^^^^^^^^^^^
10 |     print(x)
   |
help: Replace with `None`; initialize within function
   |
8  |
   - def f3(x=((x for x in "x"),)):
9  + def f3(x=None):
10 +     if x is None:
11 +         x = ((x for x in "x"),)
12 |     print(x)
   |
note: This is an unsafe fix and may change runtime behavior

B006 [*] Do not use mutable data structures for argument defaults
  --> B006_9.py:13:11
   |
13 | def f4(x=(z := [1, ])):
   |           ^^^^^^^^^^
14 |     print(x)
   |
help: Replace with `None`; initialize within function
   |
12 |
   - def f4(x=(z := [1, ])):
13 + def f4(x=None):
14 +     if x is None:
15 +         x = (z := [1, ])
16 |     print(x)
   |
note: This is an unsafe fix and may change runtime behavior

B006 [*] Do not use mutable data structures for argument defaults
  --> B006_9.py:17:11
   |
17 | def f5(x=([1, ])):
   |           ^^^^^
18 |     print(x)
   |
help: Replace with `None`; initialize within function
   |
16 |
   - def f5(x=([1, ])):
17 + def f5(x=None):
18 +     if x is None:
19 +         x = ([1, ])
20 |     print(x)
   |
note: This is an unsafe fix and may change runtime behavior
