Skip to content

Support typing.Annotated on top of typing_extensions.Annotated #8371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'typing.Union',
'typing.Literal',
'typing_extensions.Literal',
'typing.Annotated',
'typing_extensions.Annotated',
} # type: Final

Expand Down Expand Up @@ -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)
Expand Down