Skip to content
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

feat: DataSubclassMixin #185

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat: DataSubclassMixin #185

wants to merge 5 commits into from

Conversation

msto
Copy link
Contributor

@msto msto commented Sep 10, 2024

Per Slack discussion, it'd be helpful to have a generally reusable alternate constructor for subclassed dataclasses.

I chose to implement as a mixin. I think we probably want to always have this available, so I could see an argument for defining an alternate dataclass decorator that calls dataclasses.dataclass and injects this class method, to save a bit of verbosity, but this is a simple solution.

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.39%. Comparing base (c13d3cc) to head (60a63a6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #185      +/-   ##
==========================================
+ Coverage   89.35%   89.39%   +0.04%     
==========================================
  Files          18       18              
  Lines        2094     2103       +9     
  Branches      464      467       +3     
==========================================
+ Hits         1871     1880       +9     
  Misses        146      146              
  Partials       77       77              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@clintval clintval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use this!!

fgpyo/util/dataclasses.py Outdated Show resolved Hide resolved
fgpyo/util/dataclasses.py Outdated Show resolved Hide resolved
fgpyo/util/dataclasses.py Outdated Show resolved Hide resolved
fgpyo/util/dataclasses.py Outdated Show resolved Hide resolved
fgpyo/util/dataclasses.py Outdated Show resolved Hide resolved
@clintval clintval assigned msto and unassigned clintval Sep 10, 2024
@msto msto assigned tfenne and unassigned msto Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants