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

Submission for SC consideration: PEP 681 -- Data Class Transforms #117

Closed
debonte opened this issue Apr 1, 2022 · 11 comments
Closed

Submission for SC consideration: PEP 681 -- Data Class Transforms #117

debonte opened this issue Apr 1, 2022 · 11 comments

Comments

@debonte
Copy link

debonte commented Apr 1, 2022

Please consider PEP 681 for inclusion in Python 3.11.

This is a typing PEP that provides a way to describe the behavior of dataclass-like libraries to static type checkers.

The PEP has been discussed at length in several typing-sig threads:

We also posted an RFC notification on discuss.python.org pointing to the canonical thread on typing-sig.

There is a reference implementation of the type checking part in Pyright, and an implementation of the dataclass_transform decorator in typing_extensions.py.

CC: @JelleZijlstra @erictraut

https://www.python.org/dev/peps/pep-0681/

@brettcannon
Copy link
Member

I've added the PEP to our agenda.

@encukou
Copy link
Member

encukou commented Apr 4, 2022

@gvanrossum & @JelleZijlstra, what is the typing-sig consensus on this?

@JelleZijlstra
Copy link
Member

I guess we'll start the process you laid out on typing-sig :)

Sentiment has been generally positive but I can send a fuller summary later today after consulting with Guido.

@JelleZijlstra
Copy link
Member

@gvanrossum and I discussed the PEP today and we recommend accepting it.

Some main points:

  • The PEP addresses an important pain point with typing for users of many widely used libraries.
  • There has been mostly positive feedback, including from the maintainers of target libraries such as attrs, pydantic, and SQLAlchemy, and also from the maintainers of other type checkers.
  • We had some concerns around locking in a feature that is currently specific to Pyright (as far as I can tell, no other type checker has implemented the PEP yet) and may not cover the needs of all libraries. However, the PEP explicitly keeps the door open to add additional customization options in the future, and we have a mechanism (typing-extensions) to distribute such changes to users.

I collected discussion links in python/peps#2502 (both mailing lists and the Pyright issue tracker).

@erictraut
Copy link

as far as I can tell, no other type checker has implemented the PEP yet

I think that pyre has also implemented support for it already. @pradeep90 or @shannonzhu could confirm.

@pradeep90
Copy link

Yes, Pyre has partially implemented dataclass-transform. We support the decorator function and class examples and are yet to handle the metaclass example.

Overall, Pyre is +1 on this PEP as it will save us from maintaining custom support for N dataclass-like frameworks and will automatically enable ones we don't yet support (such as Pydantic).

@gvanrossum
Copy link
Member

Jelle and I discussed it this morning and I am indeed onboard with this. I hope the SC adopts our recommendation!

@debonte
Copy link
Author

debonte commented Apr 11, 2022

Sent RFC to python-dev as requested by @brettcannon -- https://mail.python.org/archives/list/python-dev@python.org/thread/7MEB5WYMUZ6SPEVZMVG5H7NQRI7KRB25/

@JelleZijlstra
Copy link
Member

Has the SC discussed the PEP again? We made the changes requested in the SC's previous communication and implemented it for 3.11, but there's no formal acceptance yet.

@brettcannon
Copy link
Member

I have made sure it's back on the agenda (PyCon US + illness + vacation is meant not much has happened since our comments).

@encukou
Copy link
Member

encukou commented Jun 6, 2022

It's now accepted: https://mail.python.org/archives/list/python-dev@python.org/message/R4A2IYLGFHKFDYJPSDA5NFJ6N7KRPJ6D/
Thank you for your patience!

@encukou encukou closed this as completed Jun 6, 2022
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

No branches or pull requests

7 participants