---
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs
---
B006 [*] Do not use mutable data structures for argument defaults
 --> B006_8.py:1:19
  |
1 | def foo(a: list = []):
  |                   ^^
2 |     raise NotImplementedError("")
  |
help: Replace with `None`; initialize within function
  |
  - def foo(a: list = []):
1 + def foo(a: list = None):
2 |     raise NotImplementedError("")
  |
note: This is an unsafe fix and may change runtime behavior

B006 [*] Do not use mutable data structures for argument defaults
 --> B006_8.py:5:19
  |
5 | def bar(a: dict = {}):
  |                   ^^
6 |     """ This one also has a docstring"""
7 |     raise NotImplementedError("and has some text in here")
  |
help: Replace with `None`; initialize within function
  |
4 |
  - def bar(a: dict = {}):
5 + def bar(a: dict = None):
6 |     """ This one also has a docstring"""
  |
note: This is an unsafe fix and may change runtime behavior

B006 [*] Do not use mutable data structures for argument defaults
  --> B006_8.py:10:19
   |
10 | def baz(a: list = []):
   |                   ^^
11 |     """This one raises a different exception"""
12 |     raise IndexError()
   |
help: Replace with `None`; initialize within function
   |
9  |
   - def baz(a: list = []):
10 + def baz(a: list = None):
11 |     """This one raises a different exception"""
12 +     if a is None:
13 +         a = []
14 |     raise IndexError()
   |
note: This is an unsafe fix and may change runtime behavior

B006 [*] Do not use mutable data structures for argument defaults
  --> B006_8.py:15:19
   |
15 | def qux(a: list = []):
   |                   ^^
16 |     raise NotImplementedError
   |
help: Replace with `None`; initialize within function
   |
14 |
   - def qux(a: list = []):
15 + def qux(a: list = None):
16 |     raise NotImplementedError
   |
note: This is an unsafe fix and may change runtime behavior

B006 [*] Do not use mutable data structures for argument defaults
  --> B006_8.py:19:20
   |
19 | def quux(a: list = []):
   |                    ^^
20 |     raise NotImplemented
   |
help: Replace with `None`; initialize within function
   |
18 |
   - def quux(a: list = []):
19 + def quux(a: list = None):
20 |     raise NotImplemented
   |
note: This is an unsafe fix and may change runtime behavior
