Skip to content
Closed
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
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3792,7 +3792,7 @@ def analyze_type_application(self, expr: IndexExpr) -> None:
# ...or directly.
else:
n = self.lookup_type_node(base)
if n and n.fullname in nongen_builtins:
if n and n.fullname in nongen_builtins and not self.is_future_flag_set("annotations"):
self.fail(no_subscript_builtin_alias(n.fullname, propose_alt=False), expr)

def analyze_type_application_args(self, expr: IndexExpr) -> Optional[List[Type]]:
Expand Down
9 changes: 9 additions & 0 deletions test-data/unit/check-future.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,14 @@ t1: type[int]
t2: list[int]
t3: dict[int, int]
t4: tuple[int, str, int]
t5 = list[int]

[builtins fixtures/dict.pyi]

[case testFutureAnnotationsMissing]
# flags: --python-version 3.7

t1: list[int] # E: "list" is not subscriptable, use "typing.List" instead
t2 = list[int] # E: "list" is not subscriptable

[builtins fixtures/list.pyi]