Pass kwargs to post init in dataclasses#3771
Merged
Wauplin merged 2 commits intohuggingface:mainfrom Feb 4, 2026
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3771 +/- ##
==========================================
+ Coverage 75.00% 76.56% +1.55%
==========================================
Files 145 153 +8
Lines 13978 15086 +1108
==========================================
+ Hits 10484 11550 +1066
- Misses 3494 3536 +42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Wauplin
approved these changes
Feb 4, 2026
Contributor
Wauplin
left a comment
There was a problem hiding this comment.
Thanks for the PR @zucchini-nlp! Makes perfect sense yes. I've updated the PR to add back the default behavior of setting kwargs as attributes but it can now be overwritten. I'll merge the PR now (failing CI is unrelated) and we'll ship it very soon :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per title, needed for huggingface/transformers#41250. I verified that it is the easiest way to keep BC for remote code, because we can't force everyone to use
dataclassesas configsWe don't want to set
kwargsas attr directly, as some keys have to be popped (i.e. deprecated key) and some keys have to be transformed before setting (e.g. keyattn_implememtationis set to private_attn_implememtation_internal)While it can possibly be done in post init by manually deleting and post processing attr, imo it's cleaner to pass
kwargs