On Thu, Oct 21, 2021 at 09:36:20PM -0700, Christopher Barker wrote:
> On Thu, Oct 21, 2021 at 5:24 PM Steven D'Aprano <st...@pearwood.info> wrote:
> 
> > Runtime type checkers already have to deal with forward refs that are
> > strings, as this is legal, and always will be:
> >
> >     def function(arg:'Spam') -> Any: ...
> >
> > so we're not putting any extra burden on them. And we had already
> > agreed to implicitly use strings for annotations.
> >
> 
> I'll take your word for it. However, other runtime uses for annotations may
> not already need to support strings as types.
> 
> Pydantic is the classic example.

Pydantic supports stringified annotations.

https://pydantic-docs.helpmanual.io/usage/postponed_annotations/

Any other runtime annotation tool has to support strings, otherwise the 
"from __future__ import annotations" directive will have already broken 
it. If the tool does type-checking, then it should support stringified 
annotations. They have been a standard part of type-hinting since 2014 
and Python 3.5:

https://www.python.org/dev/peps/pep-0484/#forward-references

Any type-checking tool which does not already support stringified 
references right now is broken.


-- 
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/WVVBETE7UZ4WI6HOF7WCNHYOK6HCXRTA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to