[issue44807] typing.Protocol silently overrides __init__ method of delivered class
Jelle Zijlstra
report at bugs.python.org
Mon Feb 28 22:20:11 EST 2022
Jelle Zijlstra <jelle.zijlstra at gmail.com> added the comment:
Regardless of mypy's behavior (which isn't impacted by what typing.py does), there's a legitimate complaint here about the runtime behavior: any `__init__` method defined in a Protocol gets silently replaced.
>>> from typing import Protocol
>>> class X(Protocol):
... def __init__(self, x, y): pass
...
>>> X.__init__
<function _no_init_or_replace_init at 0x10de4e5c0>
Fixing that won't be easy though, unless we give up on making it impossible to instantiate a Protocol.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44807>
_______________________________________
More information about the Python-bugs-list
mailing list