[New-bugs-announce] [issue36042] Setting __init_subclass__ and __class_getitem__ methods are in runtime doesnt make them class method.
BTaskaya
report at bugs.python.org
Tue Feb 19 12:19:55 EST 2019
New submission from BTaskaya <batuhanosmantaskaya at gmail.com>:
CPython only makes these methods class method when a class created. If you set __class_getitem__ method after the creation it doesn't work unless you use classmethod decorator manually.
>>> class B:
... pass
...
>>> def y(*a, **k):
... return a, k
...
>>> B.__class_getitem__ = y
>>> B[int]
((<class 'int'>,), {})
>>> B.__class_getitem__ = classmethod(y)
>>> B[int]
((<class '__main__.B'>, <class 'int'>), {})
----------
messages: 335985
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Setting __init_subclass__ and __class_getitem__ methods are in runtime doesnt make them class method.
type: behavior
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36042>
_______________________________________
More information about the New-bugs-announce
mailing list