-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ruff
] Implicit class variable in dataclass (RUF045
)
#14349
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF045 | 8 | 8 | 0 | 0 | 0 |
False positives found by ecosystem checks:
@dataclass
class FontFace:
family: str | None
emphasis: TextEmphasis | None
size_pt: int | None
color: DeviceGray | DeviceRGB | None
fill_color: DeviceGray | DeviceRGB | None
...
replace = dataclasses.replace
@dataclasses.dataclass(frozen=True)
class FuncFixtureInfo:
...
__slots__ = ("argnames", "initialnames", "names_closure", "name2fixturedefs") Special names can be exempted, but I'm not sure what to do about the first. |
I'm not saying we shouldn't do it, but requiring type annotations has been controversial in other instances; for example, there's a long thread for RUF012 that does something similar. @AlexWaygood I'd be interested on your take on this before I start reviewing the rule itself. |
641759f
to
404fa94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Looking at the ecosystem results, it seems fairly common for users to define a private class variable in their dataclasses. So I've restricted the scope of the rule a little to exempt that.
Summary
Resolves #12877.
Test Plan
cargo nextest run
andcargo insta test
.