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 as A2(*args, **kw) instead of the expected A2(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 that help(A1) works correctly and shows the correct signature as A1(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
Linked PRs
Bug report
With the following class hierarchy:
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__:Note that
help(A1)works correctly and shows the correct signature asA1(a, b):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
Linked PRs