This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Subclassing Protocol get different __init__
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: kj, lukasz.langa, miss-islington, serhiy.storchaka, uriyyo
Priority: normal Keywords: patch

Created on 2021-08-02 09:20 by uriyyo, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27541 closed uriyyo, 2021-08-02 09:35
PR 27545 merged serhiy.storchaka, 2021-08-02 11:39
PR 27558 merged miss-islington, 2021-08-02 16:23
PR 27559 merged miss-islington, 2021-08-02 16:23
PR 27543 uriyyo, 2021-08-02 16:30
Messages (5)
msg398736 - (view) Author: Yurii Karabas (uriyyo) * (Python triager) Date: 2021-08-02 09:20
When we subclassing Protocol, we get a __init__ differing from default one but the protocol in question didn't define any __init__.

More information can be found here - https://github.com/python/typing/issues/644
msg398756 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-08-02 11:45
There is other related case:

>>> from typing import *
>>> class P(Protocol): pass
... 
>>> class B:
...     def __init__(self):
...         self.test = 'OK'
... 
>>> class D(P, B):
...     pass
... 
>>> D().test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'D' object has no attribute 'test'
msg398780 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-02 16:23
New changeset 043cd60abed09edddc7185bcf7d039771acc734d by Serhiy Storchaka in branch 'main':
bpo-44806: Fix __init__ in subclasses of protocols (GH-27545)
https://github.com/python/cpython/commit/043cd60abed09edddc7185bcf7d039771acc734d
msg398782 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-02 16:52
New changeset 0f6a7739df0055b5c6abe2180f1be97ea4da87b7 by Miss Islington (bot) in branch '3.9':
bpo-44806: Fix __init__ in subclasses of protocols (GH-27545) (GH-27559)
https://github.com/python/cpython/commit/0f6a7739df0055b5c6abe2180f1be97ea4da87b7
msg398785 - (view) Author: miss-islington (miss-islington) Date: 2021-08-02 17:09
New changeset 2cc19a5463c804b2f39b94de896d55dcb57a364c by Miss Islington (bot) in branch '3.10':
bpo-44806: Fix __init__ in subclasses of protocols (GH-27545)
https://github.com/python/cpython/commit/2cc19a5463c804b2f39b94de896d55dcb57a364c
History
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 88969
2021-08-02 17:37:34lukasz.langasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-08-02 17:09:07miss-islingtonsetmessages: + msg398785
2021-08-02 16:52:32lukasz.langasetmessages: + msg398782
2021-08-02 16:30:30uriyyosetpull_requests: + pull_request26068
2021-08-02 16:23:38miss-islingtonsetpull_requests: + pull_request26065
2021-08-02 16:23:33lukasz.langasetnosy: + lukasz.langa
messages: + msg398780
2021-08-02 16:23:32miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26064
2021-08-02 11:45:21serhiy.storchakasetmessages: + msg398756
2021-08-02 11:39:59serhiy.storchakasetpull_requests: + pull_request26054
2021-08-02 09:35:30uriyyosetkeywords: + patch
stage: patch review
pull_requests: + pull_request26050
2021-08-02 09:29:59serhiy.storchakasetnosy: + serhiy.storchaka

versions: + Python 3.9, Python 3.10
2021-08-02 09:20:47uriyyocreate