diff --git a/mypy/semanal.py b/mypy/semanal.py index 2ea444bf4ab2..19fa9c633b0d 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -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]]: diff --git a/test-data/unit/check-future.test b/test-data/unit/check-future.test index 9ccf4eaa3dd2..28947d10ee8b 100644 --- a/test-data/unit/check-future.test +++ b/test-data/unit/check-future.test @@ -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]