---
source: crates/ruff_linter/src/rules/ruff/mod.rs
---
RUF009 Do not perform function call `default_function` in dataclass defaults
  --> RUF009_attrs.py:46:41
   |
44 | @define
45 | class B:
46 |     hidden_mutable_default: list[int] = default_function()
   |                                         ^^^^^^^^^^^^^^^^^^
47 |     another_dataclass: A = A()
48 |     not_optimal: ImmutableType = ImmutableType(20)
   |

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

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

RUF009 Do not perform function call `F` in dataclass defaults
   --> RUF009_attrs.py:108:12
    |
106 | @attr.attrs
107 | class H:
108 |     f: F = F()
    |            ^^^
109 |     g: G = G()
    |

RUF009 Do not perform function call `G` in dataclass defaults
   --> RUF009_attrs.py:109:12
    |
107 | class H:
108 |     f: F = F()
109 |     g: G = G()
    |            ^^^
    |

RUF009 Do not perform function call `F` in dataclass defaults
   --> RUF009_attrs.py:114:12
    |
112 | @attr.define
113 | class I:
114 |     f: F = F()
    |            ^^^
115 |     g: G = G()
    |

RUF009 Do not perform function call `G` in dataclass defaults
   --> RUF009_attrs.py:115:12
    |
113 | class I:
114 |     f: F = F()
115 |     g: G = G()
    |            ^^^
    |

RUF009 Do not perform function call `F` in dataclass defaults
   --> RUF009_attrs.py:120:12
    |
118 | @attr.frozen
119 | class J:
120 |     f: F = F()
    |            ^^^
121 |     g: G = G()
    |

RUF009 Do not perform function call `G` in dataclass defaults
   --> RUF009_attrs.py:121:12
    |
119 | class J:
120 |     f: F = F()
121 |     g: G = G()
    |            ^^^
    |

RUF009 Do not perform function call `F` in dataclass defaults
   --> RUF009_attrs.py:126:12
    |
124 | @attr.mutable
125 | class K:
126 |     f: F = F()
    |            ^^^
127 |     g: G = G()
    |

RUF009 Do not perform function call `G` in dataclass defaults
   --> RUF009_attrs.py:127:12
    |
125 | class K:
126 |     f: F = F()
127 |     g: G = G()
    |            ^^^
    |

RUF009 Do not perform function call `list` in dataclass defaults
   --> RUF009_attrs.py:144:20
    |
142 | @attr.attributes
143 | class TestAttrAttributes:
144 |     x: list[int] = list()  # RUF009
    |                    ^^^^^^
    |
