Skip to content

Type[X] not compatible with metaclass of X #3326

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
JukkaL opened this issue May 5, 2017 · 2 comments
Closed

Type[X] not compatible with metaclass of X #3326

JukkaL opened this issue May 5, 2017 · 2 comments
Labels
bug mypy got something wrong priority-1-normal

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented May 5, 2017

The second-to-last line should probably be accepted by mypy, but it currently generates an error because Type[A] isn't compatible with the metaclass of M:

from typing import Type

class M(type): pass
class A(metaclass=M): pass

a: Type[A] = A
m: M = a    # error, but should be okay
m2: M = A   # no error
@elazarg
Copy link
Contributor

elazarg commented May 9, 2017

This was introduced by me in #2837: the metaclass lookup is performed on the wrong side.

@elazarg
Copy link
Contributor

elazarg commented May 9, 2017

What's more, in the same PR I've made M compatible with Type[A], even though it is demonstrably unsafe... I would like to fix this too, but EnumMeta is relying on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-1-normal
Projects
None yet
Development

No branches or pull requests

3 participants