Skip to content
New issue

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

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

Already on GitHub? # to your account

Built-in generics as super classes #10731

Closed
srittau opened this issue Jun 28, 2021 · 0 comments · Fixed by #10766
Closed

Built-in generics as super classes #10731

srittau opened this issue Jun 28, 2021 · 0 comments · Fixed by #10766
Labels
bug mypy got something wrong

Comments

@srittau
Copy link
Contributor

srittau commented Jun 28, 2021

Bug Report

Please consider the following stub file:

class Foo(list[str]):
    bar: list[str]

When checking this with mypy --python-version=3.8 foo.pyi (mypy 0.910, Python 3.9.4), I get the following output:

foo.pyi:1: error: "list" is not subscriptable
Found 1 error in 1 file (checked 1 source file)

Please note that it complains about line 1, but not line 2. It will not complain when running in Python 3.9+ mode. See also #9980 and #10303.

@srittau srittau added the bug mypy got something wrong label Jun 28, 2021
JukkaL added a commit that referenced this issue Jul 5, 2021
This fixes these issues:

* Allow variable-length tuple (tuple[int, ...]) in type aliases
* Allow generic built-in types (e.g. list[int]) in stubs in all Python versions

Fixes #9980. Fixes #10303. Fixes #10731.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant