-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PEP 681: Data Class Transforms #2285
Conversation
From https://www.attrs.org/en/stable/api.html#attr.ib it looks like the converter is just passed the input value; the previous wording here sounded like the converter itself got passed a callable.
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.
Congratulations! I have a few small pieces of feedback and then we can merge the PR.
@CAM-Gerlach Thanks. I hadn't seen GitHub suggestions before and only noticed them on Jelle's comments after I addressed his changes. I'll use them going forward... |
Great, thanks @debonte ! BTW, I'll use another of GitHub's features and mark this PR as a draft while I'm reviewing, to avoid it unintentionally getting merged while I'm halfway through. |
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.
Great job overall! Its a lot of little comments (if I'd known, I'd have considered making a separate PR, sorry), but mostly clarifications reST syntax changes, grammar tweaks, de-redundantizing some parts, and other little things like that, plus a few questions about parts I was unclear on as a reader. I suggest you apply the suggestions all in one batch, and then pulling that and then considering making the few larger changes after. Thanks!
Open Issues | ||
=========== | ||
|
||
``converter`` field descriptor parameter |
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.
Doesn't pydantic have this too—in fact, isn't it one of its central features? Might be worth mentioning here, especially given its greater modern popularity relative to attrs
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.
Could be. Unfortunately I'm not a pydantic expert. I scanned through their docs and didn't see anything similar.
@samuelcolvin, does pydantic have a feature similar to attrs' converter field descriptor parameter?
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
@AA-Turner There were multiple syntax errors (three |
Will have a look, thanks for the note. |
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.
Thanks! Some minor fixes to my own typos should get the build working again, my fault. And sorry again for all the comment noise; in the future I can do it as a PR to your branch or similar.
(@AA-Turner We use |
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
@AA-Turner See my reply on #2288 (to avoid derailing this PR further). |
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.
Just a bit of final cleanup of a couple of my minor mistakes and a few style nits; otherwise LGTM! Thanks @debonte!
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
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.
LGTM, thanks @debonte ! I'll leave this up to @JelleZijlstra to merge.
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.
Thanks! I'll merge once CI passes.
@JelleZijlstra there are still a couple open comments on this PR. Should I address them in a separate PR? |
Sure. It looks like all of the remaining items are open-ended and may not lead to changes in the PEP. If you do decide to change something, I can merge some PRs. |
This new PEP introduces the dataclass_transform decorator, enabling dataclass-like libraries to describe their behavior to type checkers.
cc: @msfterictraut @JelleZijlstra