-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
gh-90669: Let typing.Annotated wrap dataclasses annotations #30997
base: main
Are you sure you want to change the base?
Conversation
This should be ready now; I think this approach is the least invasive and most maintainable: we strip annotations when we find them and otherwise adjust the regex to ignore them in leading position. The annotation stripping could be factored out to another function if we wanted. |
This code is ready for review, but I'll mention another option if you're interested: The code currently allows anything with a symbol named An even better approach is using a new regex to nibble at matches at the front of the string annotation and check one by one if they are Annotated until you reach one that isn't. This should be able to support everything. This is a lot more complicated so I don't intend to introduce it unless you see this as important. |
@ericvsmith Because my PR removing the need for passing |
We also remove the support for leading spaces in stringified dataclasses annotations (ref https://bugs.python.org/issue46552 ) and allow nested leading Annotated[] annotations (see the PEP).