Skip to content

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

Closed

Description

@JukkaL

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

Activity

  1. elazarg commented on May 9, 2017

    @elazarg
    Contributor

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

  2. elazarg commented on May 9, 2017

    @elazarg
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions