From 504157c695c7f8b418e4692d47c9931d274a3a8c Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Wed, 5 Feb 2020 15:23:51 +0100 Subject: [PATCH] Support typing.Annotated on top of typing_extensions.Annotated This is to handle PEP 593 support recently merged into CPython[1]. [1] https://github.com/python/cpython/pull/18260 --- mypy/typeanal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy/typeanal.py b/mypy/typeanal.py index ed5d0e0474e4..183a9a792c91 100644 --- a/mypy/typeanal.py +++ b/mypy/typeanal.py @@ -43,6 +43,7 @@ 'typing.Union', 'typing.Literal', 'typing_extensions.Literal', + 'typing.Annotated', 'typing_extensions.Annotated', } # type: Final @@ -311,7 +312,7 @@ def try_analyze_special_unbound_type(self, t: UnboundType, fullname: str) -> Opt return UninhabitedType(is_noreturn=True) elif fullname in ('typing_extensions.Literal', 'typing.Literal'): return self.analyze_literal_type(t) - elif fullname == 'typing_extensions.Annotated': + elif fullname in ('typing_extensions.Annotated', 'typing.Annotated'): if len(t.args) < 2: self.fail("Annotated[...] must have exactly one type argument" " and at least one annotation", t)