Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,9 @@ def visit_unbound_type(self, t: UnboundType) -> TypeVarLikeList:
return []
elif node and node.fullname in ('typing_extensions.Literal', 'typing.Literal'):
return []
elif node and node.fullname in ('typing_extensions.Annotated', 'typing.Annotated'):
elif (node
and node.fullname in ('typing_extensions.Annotated', 'typing.Annotated')
and t.args):
# Don't query the second argument to Annotated for TypeVars
return self.query_types([t.args[0]])
else:
Expand Down
7 changes: 7 additions & 0 deletions test-data/unit/semanal-errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -1435,3 +1435,10 @@ TP = ParamSpec('?') # E: String argument 1 "?" to ParamSpec(...) does not match
TP2: int = ParamSpec('TP2') # E: Cannot declare the type of a parameter specification

[out]


[case testBaseClassAnnotatedWithoutArgs]
# https://github.com/python/mypy/issues/11808
from typing_extensions import Annotated
# Nest line should not crash:
class A(Annotated): pass # E: Annotated[...] must have exactly one type argument and at least one annotation