You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that RUF009 can be a bit misleading when auto_attribs=False (or with older attr.s codebases):
importattrs@attrs.define(auto_attribs=False)classX:
a_field: int=attrs.field(default=42)
not_a_field: list= (lambda: [])()
# ^^^^^^^^^^^^^^ RUF009 Do not perform function call in dataclass defaults
Without auto_attribs, not_a_field can't possibly be a dataclass field. In this example, it's an incorrectly typed class variable. Fixing the typing error also fixes the RUF009 warning:
This is an issue though when using attrs.field wrappers:
defmy_field():
returnattrs.field(default=42, metadata={"my_metadata": 42})
@attrs.define(auto_attribs=False)classX:
a_field: int=my_field()
# ^^^^^^^^^^ RUF009 Do not perform function call `my_field` in dataclass defaults
From #14327:
The text was updated successfully, but these errors were encountered: