diff --git a/mypy/semanal.py b/mypy/semanal.py index 853917a9aadf..aca1f545c472 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -4091,6 +4091,7 @@ def analyze_type_application(self, expr: IndexExpr) -> None: name = target.type.fullname if (alias.no_args and # this avoids bogus errors for already reported aliases name in get_nongen_builtins(self.options.python_version) and + not self.is_stub_file and not alias.normalized): self.fail(no_subscript_builtin_alias(name, propose_alt=False), expr) # ...or directly. diff --git a/test-data/unit/check-generic-alias.test b/test-data/unit/check-generic-alias.test index a4c79c9c6f7f..73efbd223c6c 100644 --- a/test-data/unit/check-generic-alias.test +++ b/test-data/unit/check-generic-alias.test @@ -285,3 +285,14 @@ class C(list[int]): pass d: type[str] [builtins fixtures/list.pyi] + + +[case testTypeAliasWithBuiltinListAliasInStub] +# flags: --python-version 3.6 +import m +reveal_type(m.a()[0]) # N: Revealed type is "builtins.int*" + +[file m.pyi] +List = list +a = List[int] +[builtins fixtures/list.pyi]