Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PEP 585 type aliases in stubs #11918

Merged
merged 1 commit into from Jan 6, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions mypy/semanal.py
Expand Up @@ -4085,6 +4085,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.
Expand Down
11 changes: 11 additions & 0 deletions test-data/unit/check-generic-alias.test
Expand Up @@ -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]