Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The help function shows incorrect signature for subclass #105080

Closed
Labels
stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@danpascu

Description

@danpascu

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp