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

PEP 681: Data Class Transforms #2285

Merged
merged 36 commits into from
Jan 31, 2022
Merged

Conversation

debonte
Copy link
Contributor

@debonte debonte commented Jan 28, 2022

This new PEP introduces the dataclass_transform decorator, enabling dataclass-like libraries to describe their behavior to type checkers.

cc: @msfterictraut @JelleZijlstra

debonte and others added 24 commits January 27, 2022 18:55
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.
@debonte debonte requested a review from a team as a code owner January 28, 2022 03:18
Copy link
Member

@JelleZijlstra JelleZijlstra left a 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.

.github/CODEOWNERS Outdated Show resolved Hide resolved
pep-9999.rst Outdated Show resolved Hide resolved
pep-9999.rst Outdated Show resolved Hide resolved
pep-9999.rst Outdated Show resolved Hide resolved
pep-9999.rst Outdated Show resolved Hide resolved
pep-9999.rst Outdated Show resolved Hide resolved
@debonte
Copy link
Contributor Author

debonte commented Jan 28, 2022

just making sure — you know how to apply GitHub suggestions, right?

@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...

@CAM-Gerlach
Copy link
Member

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.

@CAM-Gerlach CAM-Gerlach marked this pull request as draft January 28, 2022 06:42
Copy link
Member

@CAM-Gerlach CAM-Gerlach left a 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!

pep-0681.rst Outdated Show resolved Hide resolved
pep-0681.rst Show resolved Hide resolved
pep-0681.rst Outdated Show resolved Hide resolved
pep-0681.rst Outdated Show resolved Hide resolved
pep-0681.rst Outdated Show resolved Hide resolved
pep-0681.rst Outdated Show resolved Hide resolved
pep-0681.rst Outdated Show resolved Hide resolved
pep-0681.rst Show resolved Hide resolved
Open Issues
===========

``converter`` field descriptor parameter
Copy link
Member

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

Copy link
Contributor Author

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?

pep-0681.rst Outdated Show resolved Hide resolved
@CAM-Gerlach CAM-Gerlach marked this pull request as ready for review January 28, 2022 09:33
debonte and others added 2 commits January 28, 2022 11:10
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
@CAM-Gerlach
Copy link
Member

@AA-Turner There were multiple syntax errors (three ... in front of a directive, a stray ```suggestion, a bad link target name, etc) that the legacy build correctly failed on, and Sphinx printed ERRORs in the output, but Sphinx still finished building and returned 0, making the CI pass. Is there any way we can set Sphinx to fail on such errors, but not on warnings? I thought it did already, and I can't seem to repro it locally since they only print as WARNINGs to begin with on my end, so I'm not sure what's going on.

@AA-Turner
Copy link
Member

Will have a look, thanks for the note.
A

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a 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.

pep-0681.rst Outdated Show resolved Hide resolved
pep-0681.rst Outdated Show resolved Hide resolved
pep-0681.rst Outdated Show resolved Hide resolved
@CAM-Gerlach
Copy link
Member

(@AA-Turner We use --fail-on-warning --nitpicky to do that, but that won't work here until we fix the remaining warnings)

Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
@AA-Turner AA-Turner changed the title New PEP: Data Class Transforms PEP 681: Data Class Transforms Jan 28, 2022
@AA-Turner
Copy link
Member

Sphinx still finished building and returned 0, making the CI pass. Is there any way we can set Sphinx to fail on such errors, but not on warnings?

Fixed in #2288, you should be able to test with the bad commit bd3275f

I can't seem to repro it locally

You probably have Sphinx 4.3.*, not 4.4.0

A

@CAM-Gerlach
Copy link
Member

@AA-Turner See my reply on #2288 (to avoid derailing this PR further).

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a 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!

pep-0681.rst Show resolved Hide resolved
pep-0681.rst Outdated Show resolved Hide resolved
pep-0681.rst Outdated Show resolved Hide resolved
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Copy link
Member

@CAM-Gerlach CAM-Gerlach left a 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.

Copy link
Member

@JelleZijlstra JelleZijlstra left a 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 JelleZijlstra merged commit 47de64f into python:main Jan 31, 2022
@debonte
Copy link
Contributor Author

debonte commented Jan 31, 2022

@JelleZijlstra there are still a couple open comments on this PR. Should I address them in a separate PR?

@JelleZijlstra
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants