Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
Closed
Description
Bug report
With the following class hierarchy:
classA0:def__new__(cls,*args,**kw):returnsuper().__new__(cls)def__init__(self,*args,**kw):super().__init__()classA1(A0):def__init__(self,a,b):super().__init__()self.a=aself.b=bclassA2(A1):c=None
help(A2)
shows the wrong signature for instantiating A2 asA2(*args, **kw)
instead of the expectedA2(a, b)
, despite the fact that is shows the correct signature for__init__
:
Help on class A2 in module __main__:class A2(A1) | A2(*args, **kw) | | Method resolution order: | A2 | A1 | A0 | builtins.object | | Data and other attributes defined here: | | c = None | | ---------------------------------------------------------------------- | Methods inherited from A1: | | __init__(self, a, b) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from A0: | | __new__(cls, *args, **kw) | Create and return a new object. See help(type) for accurate signature. | ...
Note thathelp(A1)
works correctly and shows the correct signature asA1(a, b)
:
Help on class A1 in module __main__:class A1(A0) | A1(a, b) | | Method resolution order: | A1 | A0 | builtins.object | | Methods defined here: | | __init__(self, a, b) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from A0: | | __new__(cls, *args, **kw) | Create and return a new object. See help(type) for accurate signature. | ...
This doesn't seem to be an issue if__new__
is not defined on A0, or if A1 redefines__new__
with the same signature as__init__
.
Your environment
- CPython versions tested on: 3.11.3+
- Operating system and architecture: Linux x86