---
source: crates/ruff_linter/src/rules/ruff/mod.rs
---
RUF009.py:20:41: RUF009 Do not perform function call `default_function` in dataclass defaults
   |
18 | @dataclass()
19 | class A:
20 |     hidden_mutable_default: list[int] = default_function()
   |                                         ^^^^^^^^^^^^^^^^^^ RUF009
21 |     class_variable: typing.ClassVar[list[int]] = default_function()
22 |     another_class_var: ClassVar[list[int]] = default_function()
   |

RUF009.py:43:41: RUF009 Do not perform function call `default_function` in dataclass defaults
   |
41 | @dataclass
42 | class B:
43 |     hidden_mutable_default: list[int] = default_function()
   |                                         ^^^^^^^^^^^^^^^^^^ RUF009
44 |     another_dataclass: A = A()
45 |     not_optimal: ImmutableType = ImmutableType(20)
   |

RUF009.py:44:28: RUF009 Do not perform function call `A` in dataclass defaults
   |
42 | class B:
43 |     hidden_mutable_default: list[int] = default_function()
44 |     another_dataclass: A = A()
   |                            ^^^ RUF009
45 |     not_optimal: ImmutableType = ImmutableType(20)
46 |     good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES
   |

RUF009.py:45:34: RUF009 Do not perform function call `ImmutableType` in dataclass defaults
   |
43 |     hidden_mutable_default: list[int] = default_function()
44 |     another_dataclass: A = A()
45 |     not_optimal: ImmutableType = ImmutableType(20)
   |                                  ^^^^^^^^^^^^^^^^^ RUF009
46 |     good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES
47 |     okay_variant: A = DEFAULT_A_FOR_ALL_DATACLASSES
   |


