Message403782
If I make a explicit subclass of a protocol that also inherits from a mixin and calls super() in order to initialize the mixin, I get the "Protocols cannot be instantiated" exception.
This case arises when having a hierarchy of both protocols and concrete classes that implement the protocols.
A simple example is:
import typing
class P(typing.Protocol):
def m1(self) -> None: ...
class M:
def __init__(self) -> None:
super().__init__()
self.o = True
class C(M, P):
def __init__(self) -> None:
super().__init__()
self.op = True
def m1(self) -> None:
pass
c = C()
I can resolve this in particular cases by not invoking super in the mixin or putting a special no-super class in the hierarchy. However, that is not a general solution and once the class hierarchy gets more complicated, it fails to work.
Am I missing any known solution to this issue? |
|
Date |
User |
Action |
Args |
2021-10-13 02:09:30 | cmeyer | set | recipients:
+ cmeyer |
2021-10-13 02:09:30 | cmeyer | set | messageid: <1634090970.26.0.320360946482.issue45454@roundup.psfhosted.org> |
2021-10-13 02:09:30 | cmeyer | link | issue45454 messages |
2021-10-13 02:09:30 | cmeyer | create | |
|