![](https://secure.gravatar.com/avatar/5615a372d9866f203a22b2c437527bbb.jpg?s=120&d=mm&r=g)
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 <steve@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