mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-44807: Allow Protocol classes to define __init__ (GH-31628)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
b0b836b20c
commit
5f2abae61e
3 changed files with 29 additions and 1 deletions
|
@ -1997,7 +1997,8 @@ class Protocol(Generic, metaclass=_ProtocolMeta):
|
|||
issubclass(base, Generic) and base._is_protocol):
|
||||
raise TypeError('Protocols can only inherit from other'
|
||||
' protocols, got %r' % base)
|
||||
cls.__init__ = _no_init_or_replace_init
|
||||
if cls.__init__ is Protocol.__init__:
|
||||
cls.__init__ = _no_init_or_replace_init
|
||||
|
||||
|
||||
class _AnnotatedAlias(_GenericAlias, _root=True):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue