This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author GBeauregard
Recipients GBeauregard, JelleZijlstra, eric.smith
Date 2022-01-26.07:15:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643181331.81.0.97619315778.issue46511@roundup.psfhosted.org>
In-reply-to
Content
Thanks for getting back so quickly.

Annotated is set up to be 'transparent' by default to `typing.get_type_hints` so in the case of using `typing.py` it can be made straightforward by chaining with `typing.get_origin`, I think.

I don't see any reasonable way to do the regex that allows `Annotated` to be renamed, so I agree your suggested restriction. I think the regex would be something like this:

^\s*(?:(?:\w+\s*\.)?\s*Annotated\[)?(?:\s*(\w+)\s*\.)?\s*(\w+)

I'm a bit worried people who are into Annotated annotations might be concerned about line length and more likely to rename `Annotated`, but I don't know if this is a realistic concern. And a part of me wants to say always importing typing.py should be okay since dataclasses was designed to work with type hints after all.

On the other hand, I'm also a bit worried that if we made dataclasses always import typing.py it would rub people the wrong way even if we profiled it and decided it was okay.

I'm going to spend some more time digesting the code tomorrow and try to decide if there's any major speed bumps to a full `typing` approach. I'll also look at import time and such.
History
Date User Action Args
2022-01-26 07:15:31GBeauregardsetrecipients: + GBeauregard, eric.smith, JelleZijlstra
2022-01-26 07:15:31GBeauregardsetmessageid: <1643181331.81.0.97619315778.issue46511@roundup.psfhosted.org>
2022-01-26 07:15:31GBeauregardlinkissue46511 messages
2022-01-26 07:15:31GBeauregardcreate