Gregory Beauregard <g...@greg.red> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46511>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to