diff --git a/mypy/exprtotype.py b/mypy/exprtotype.py index 5a22b9c3c759..1c9323be056d 100644 --- a/mypy/exprtotype.py +++ b/mypy/exprtotype.py @@ -122,7 +122,7 @@ def expr_to_unanalyzed_type( else: base_fullname = expr.base.fullname - if base_fullname is not None and base_fullname in ANNOTATED_TYPE_NAMES: + if base_fullname is not None and base_fullname in ANNOTATED_TYPE_NAMES and args: # TODO: this is not the optimal solution as we are basically getting rid # of the Annotation definition and only returning the type information, # losing all the annotations. diff --git a/test-data/unit/check-annotated.test b/test-data/unit/check-annotated.test index d4de3f7b5043..03ae8906f1d3 100644 --- a/test-data/unit/check-annotated.test +++ b/test-data/unit/check-annotated.test @@ -41,6 +41,11 @@ x: Annotated[int] # E: Annotated[...] must have exactly one type argument and a reveal_type(x) # N: Revealed type is "Any" [builtins fixtures/tuple.pyi] +[case testAnnotatedBadEmptyTupleIndexInTypeApplication] +from typing_extensions import Annotated +list[Annotated[()]] # E: Annotated[...] must have exactly one type argument and at least one annotation +[builtins fixtures/list.pyi] + [case testAnnotatedNested0] from typing_extensions import Annotated x: Annotated[Annotated[int, ...], ...]