Closed jtatum closed 2 years ago
ABC.register() is not supported and it's unclear to me how it could be supported without a relatively big change to mypy. It probably would require an extra pass over the code looking for register() calls everywhere.
The only thing that's easy to do is to add register() to the stubs in typeshed -- can you send a PR for that?
Hmm, there might be another issue with metaclasses that prevents me from adding register to typeshed:
class M(type):
def test(cls):
pass
class C(metaclass=M):
pass
C.test() # error: "C" has no attribute "test"
Ohh... Yes, that looks like we have a problem with metaclasses.
FWIW, this is a pretty common/frustrating bug in the Python ecosystem, here's the equivalent IntelliJ/PyCharm issue.
For ABCMeta.register()
support, see #2922 (newer issue but has more discussion than this one).
For generalised metaclass support, this example no longer reproduces on mypy 0.941.
Seeing a couple of different errors with virtual subclasses: