Title: The help function shows incorrect signature for subclass · Issue #105080 · python/cpython · GitHub
Open Graph Title: The help function shows incorrect signature for subclass · Issue #105080 · python/cpython
X Title: The help function shows incorrect signature for subclass · Issue #105080 · python/cpython
Description: Bug report With the following class hierarchy: class A0: def __new__(cls, *args, **kw): return super().__new__(cls) def __init__(self, *args, **kw): super().__init__() class A1(A0): def __init__(self, a, b): super().__init__() self.a = a...
Open Graph Description: Bug report With the following class hierarchy: class A0: def __new__(cls, *args, **kw): return super().__new__(cls) def __init__(self, *args, **kw): super().__init__() class A1(A0): def __init__(se...
X Description: Bug report With the following class hierarchy: class A0: def __new__(cls, *args, **kw): return super().__new__(cls) def __init__(self, *args, **kw): super().__init__() class A1(A0): def __init__(se...
Opengraph URL: https://github.com/python/cpython/issues/105080
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The help function shows incorrect signature for subclass","articleBody":"# Bug report\r\n\r\nWith the following class hierarchy:\r\n\r\n```py\r\nclass A0:\r\n def __new__(cls, *args, **kw):\r\n return super().__new__(cls)\r\n def __init__(self, *args, **kw):\r\n super().__init__()\r\n\r\nclass A1(A0):\r\n def __init__(self, a, b):\r\n super().__init__()\r\n self.a = a\r\n self.b = b\r\n\r\nclass A2(A1):\r\n c = None\r\n\r\n```\r\n\r\n`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__`:\r\n\r\n```\r\nHelp on class A2 in module __main__:\r\n\r\nclass A2(A1)\r\n | A2(*args, **kw)\r\n | \r\n | Method resolution order:\r\n | A2\r\n | A1\r\n | A0\r\n | builtins.object\r\n | \r\n | Data and other attributes defined here:\r\n | \r\n | c = None\r\n | \r\n | ----------------------------------------------------------------------\r\n | Methods inherited from A1:\r\n | \r\n | __init__(self, a, b)\r\n | Initialize self. See help(type(self)) for accurate signature.\r\n | \r\n | ----------------------------------------------------------------------\r\n | Static methods inherited from A0:\r\n | \r\n | __new__(cls, *args, **kw)\r\n | Create and return a new object. See help(type) for accurate signature.\r\n | \r\n...\r\n```\r\n\r\nNote that `help(A1)` works correctly and shows the correct signature as `A1(a, b)`:\r\n\r\n```\r\nHelp on class A1 in module __main__:\r\n\r\nclass A1(A0)\r\n | A1(a, b)\r\n | \r\n | Method resolution order:\r\n | A1\r\n | A0\r\n | builtins.object\r\n | \r\n | Methods defined here:\r\n | \r\n | __init__(self, a, b)\r\n | Initialize self. See help(type(self)) for accurate signature.\r\n | \r\n | ----------------------------------------------------------------------\r\n | Static methods inherited from A0:\r\n | \r\n | __new__(cls, *args, **kw)\r\n | Create and return a new object. See help(type) for accurate signature.\r\n | \r\n...\r\n```\r\n\r\nThis 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__`.\r\n\r\n# Your environment\r\n\r\n\u003c!-- Include as many relevant details as possible about the environment you experienced the bug in --\u003e\r\n\r\n- CPython versions tested on: 3.11.3+\r\n- Operating system and architecture: Linux x86\r\n\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-105217\n* gh-105257\n* gh-105274\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/danpascu","@type":"Person","name":"danpascu"},"datePublished":"2023-05-30T05:09:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":25},"url":"https://github.com/105080/cpython/issues/105080"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:621a6222-b43d-f47b-6ab7-ec2e7ff8d380 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7C8:1F1AF5:328588:4423BA:6969DA32 |
| html-safe-nonce | b19e0ae413700aee91dc264bcc47027b59ed76c8e55755b53da7822b99b83b56 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0M4OjFGMUFGNTozMjg1ODg6NDQyM0JBOjY5NjlEQTMyIiwidmlzaXRvcl9pZCI6IjEwODg3NTkxMDg5MzY1NjYyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 72252629221c585792582c7c2e299908bb64946d7a6beab8d99481b2baddff1e |
| hovercard-subject-tag | issue:1731515949 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/105080/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8573b10190af45f76868cec2511ccd09883b234475f20983c54131f53cb4f49f/python/cpython/issues/105080 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8573b10190af45f76868cec2511ccd09883b234475f20983c54131f53cb4f49f/python/cpython/issues/105080 |
| og:image:alt | Bug report With the following class hierarchy: class A0: def __new__(cls, *args, **kw): return super().__new__(cls) def __init__(self, *args, **kw): super().__init__() class A1(A0): def __init__(se... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danpascu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width