---
source: crates/ruff_linter/src/rules/flake8_pie/mod.rs
---
PIE807.py:3:44: PIE807 [*] Prefer `list` over useless lambda
  |
1 | @dataclass
2 | class Foo:
3 |     foo: List[str] = field(default_factory=lambda: [])  # PIE807
  |                                            ^^^^^^^^^^ PIE807
4 |     bar: Dict[str, int] = field(default_factory=lambda: {})  # PIE807
  |
  = help: Replace with `lambda` with `list`

ℹ Safe fix
1 1 | @dataclass
2 2 | class Foo:
3   |-    foo: List[str] = field(default_factory=lambda: [])  # PIE807
  3 |+    foo: List[str] = field(default_factory=list)  # PIE807
4 4 |     bar: Dict[str, int] = field(default_factory=lambda: {})  # PIE807
5 5 | 
6 6 | 

PIE807.py:4:49: PIE807 [*] Prefer `dict` over useless lambda
  |
2 | class Foo:
3 |     foo: List[str] = field(default_factory=lambda: [])  # PIE807
4 |     bar: Dict[str, int] = field(default_factory=lambda: {})  # PIE807
  |                                                 ^^^^^^^^^^ PIE807
  |
  = help: Replace with `lambda` with `dict`

ℹ Safe fix
1 1 | @dataclass
2 2 | class Foo:
3 3 |     foo: List[str] = field(default_factory=lambda: [])  # PIE807
4   |-    bar: Dict[str, int] = field(default_factory=lambda: {})  # PIE807
  4 |+    bar: Dict[str, int] = field(default_factory=dict)  # PIE807
5 5 | 
6 6 | 
7 7 | class FooTable(BaseTable):

PIE807.py:8:36: PIE807 [*] Prefer `list` over useless lambda
  |
7 | class FooTable(BaseTable):
8 |     foo = fields.ListField(default=lambda: [])  # PIE807
  |                                    ^^^^^^^^^^ PIE807
9 |     bar = fields.ListField(default=lambda: {})  # PIE807
  |
  = help: Replace with `lambda` with `list`

ℹ Safe fix
5 5 | 
6 6 | 
7 7 | class FooTable(BaseTable):
8   |-    foo = fields.ListField(default=lambda: [])  # PIE807
  8 |+    foo = fields.ListField(default=list)  # PIE807
9 9 |     bar = fields.ListField(default=lambda: {})  # PIE807
10 10 | 
11 11 | 

PIE807.py:9:36: PIE807 [*] Prefer `dict` over useless lambda
  |
7 | class FooTable(BaseTable):
8 |     foo = fields.ListField(default=lambda: [])  # PIE807
9 |     bar = fields.ListField(default=lambda: {})  # PIE807
  |                                    ^^^^^^^^^^ PIE807
  |
  = help: Replace with `lambda` with `dict`

ℹ Safe fix
6  6  | 
7  7  | class FooTable(BaseTable):
8  8  |     foo = fields.ListField(default=lambda: [])  # PIE807
9     |-    bar = fields.ListField(default=lambda: {})  # PIE807
   9  |+    bar = fields.ListField(default=dict)  # PIE807
10 10 | 
11 11 | 
12 12 | class FooTable(BaseTable):

PIE807.py:13:28: PIE807 [*] Prefer `list` over useless lambda
   |
12 | class FooTable(BaseTable):
13 |     foo = fields.ListField(lambda: [])  # PIE807
   |                            ^^^^^^^^^^ PIE807
14 |     bar = fields.ListField(default=lambda: {})  # PIE807
   |
   = help: Replace with `lambda` with `list`

ℹ Safe fix
10 10 | 
11 11 | 
12 12 | class FooTable(BaseTable):
13    |-    foo = fields.ListField(lambda: [])  # PIE807
   13 |+    foo = fields.ListField(list)  # PIE807
14 14 |     bar = fields.ListField(default=lambda: {})  # PIE807
15 15 | 
16 16 | 

PIE807.py:14:36: PIE807 [*] Prefer `dict` over useless lambda
   |
12 | class FooTable(BaseTable):
13 |     foo = fields.ListField(lambda: [])  # PIE807
14 |     bar = fields.ListField(default=lambda: {})  # PIE807
   |                                    ^^^^^^^^^^ PIE807
   |
   = help: Replace with `lambda` with `dict`

ℹ Safe fix
11 11 | 
12 12 | class FooTable(BaseTable):
13 13 |     foo = fields.ListField(lambda: [])  # PIE807
14    |-    bar = fields.ListField(default=lambda: {})  # PIE807
   14 |+    bar = fields.ListField(default=dict)  # PIE807
15 15 | 
16 16 | 
17 17 | @dataclass


