-
Notifications
You must be signed in to change notification settings - Fork 19
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
[SIM119] Detect potential dataclasses #37
Labels
enhancement
New feature or request
Comments
|
And the dataclass:
|
MartinThoma
changed the title
[New Rule] Detect potential dataclasses
[SIM119] Detect potential dataclasses
Feb 26, 2021
MartinThoma
added a commit
that referenced
this issue
Feb 28, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explanation
Dataclasses were introduced with PEP 557. Data Classes can be thought of as "mutable namedtuples with defaults".
Dataclasses should be used when the primary focus is to store data.
Dataclasses help, because they have a good
__str__
and__eq__
implementation and you don't have to write__init__
.Example
As an example why dataclasses are nice:
gives:
The text was updated successfully, but these errors were encountered: