Skip to content

"error: Invalid type" when inheriting from a generic class with not all type variables fixed #1936

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

Closed
jstasiak opened this issue Jul 25, 2016 · 2 comments

Comments

@jstasiak
Copy link
Contributor

Code taken straight from typing documentation (https://docs.python.org/3/library/typing.html#typing.Generic):

from typing import TypeVar, Mapping

T = TypeVar('T')

class MyDict(Mapping[str, T]):
    pass

Outcome (with both latest mypy from PyPI and development version):

% python -m mypy qwe.py
qwe.py:5: error: Invalid type "qwe.T"
@rwbarton
Copy link
Contributor

IMO, the example is wrong, and should be class MyDict(Mapping[str, T], Generic[T]): ....

@JukkaL
Copy link
Collaborator

JukkaL commented Jul 25, 2016

In many cases Generic should be optional: https://www.python.org/dev/peps/pep-0484/#arbitrary-generic-types-as-base-classes

Closing as a duplicate of #302.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants