classification
Title: PEP487 __init_subclass__ incompatible with abc.ABCMeta
Type: behavior Stage: resolved
Components: Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: __init_subclass__ causes TypeError when used with standard library metaclasses (such as ABCMeta)
View: 29581
Assigned To: Nosy List: Brian Petersen, xiang.zhang
Priority: normal Keywords:

Created on 2017-03-27 20:15 by Brian Petersen, last changed 2017-03-28 04:57 by xiang.zhang. This issue is now closed.

Messages (2)
msg290641 - (view) Author: Brian Petersen (Brian Petersen) Date: 2017-03-27 20:15
First time issue reporter here.  I really love PEP 487, but I'm finding the new __init_subclass__ functionality is not playing nicely with existing abstract class functionality.

For example, taking the Quest example given in PEP 487 but simply adding ABCMeta metaclass results in a runtime error:

```
class QuestBase(metaclass=abc.ABCMeta):
    # this is implicitly a @classmethod (see below for motivation)
    def __init_subclass__(cls, swallow, **kwargs):
        cls.swallow = swallow
        super().__init_subclass__(**kwargs)

class Quest(QuestBase, swallow="african"):
   pass

print(Quest.swallow)


Traceback (most recent call last):
  File "credentials.py", line 23, in <module>
    class Quest(QuestBase, swallow="african"):
TypeError: __new__() got an unexpected keyword argument 'swallow'
```
msg290681 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-03-28 04:57
#29581 has reported a same one. :-)
History
Date User Action Args
2017-03-28 04:57:53xiang.zhangsetstatus: open -> closed

superseder: __init_subclass__ causes TypeError when used with standard library metaclasses (such as ABCMeta)

nosy: + xiang.zhang
messages: + msg290681
resolution: duplicate
stage: resolved
2017-03-27 20:17:48Brian Petersensettype: behavior
components: - Library (Lib)
2017-03-27 20:15:16Brian Petersencreate