-
Notifications
You must be signed in to change notification settings - Fork 9
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
Python 3.10 pattern matching #47
Comments
This is done in dataclasses at https://github.com/python/cpython/blob/8ab5b7eecaa1a1a249afbd3bf8358ce2b12e4713/Lib/dataclasses.py#L1089-L1092 where |
Thanks for the info @tirkarthi, I knew from the PEP what to put in the attribute but didn't realise dataclasses had a decorator option for it. Not sure why, seems like there is no downside to generating it? |
There is no backwards compatibility issue but some users wanted an option to turn it off. Detailed discussion : https://bugs.python.org/issue43764 I added support for attrs too to support pattern matching. It also added match_args parameter. |
Off topic but dataclasses also supports kw_only and slots too . Doc issue https://bugs.python.org/issue43997 |
I see. |
I set up a new branch |
Classes should support the PEP 622 Structural Pattern Matching feature of Python 3.10. From reading the PEP it seems this should be rather simple, simply adding a
__match_args__
tuple which is the same as the arguments to__init__
.The text was updated successfully, but these errors were encountered: