Ian Good <i...@icgood.net> added the comment:

Julian,

That is certainly a workaround, however the behavior you are describing is 
inconsistent with PEP-544 in both word and intention. From the PEP:

> To explicitly declare that a certain class implements a given protocol, it 
> can be used as a regular base class.

It further describes the semantics of inheriting as "unchanged" from a "regular 
base class". If the semantics are "unchanged" then it should follow that 
super().__init__() would pass through the protocol to the object.__init__, just 
like a "regular base class" would if it does not override __init__.

Furthermore, the intention of inheriting a Protocol as described in the PEP:

> Static analysis tools are expected to automatically detect that a class 
> implements a given protocol. So while it's possible to subclass a protocol 
> explicitly, it's not necessary to do so for the sake of type-checking.

The purpose of adding a Protocol sub-class as an explicit base class is thus 
only to improve static analysis, it should *not* to modify the runtime 
semantics.

Consider the case where a package maintainer wants to enhance the flexibility 
of their types by transitioning from using an ABC to using structural 
sub-typing. That simple typing change would be a breaking change to the package 
consumers, who must now remove a super().__init__() call.

Ian

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45081>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to