Title: __signature__ in the inspect module · Issue #106310 · python/cpython · GitHub
Open Graph Title: __signature__ in the inspect module · Issue #106310 · python/cpython
X Title: __signature__ in the inspect module · Issue #106310 · python/cpython
Description: Documentation The __signature__ attribute is treated by inspect.signature (and inspect.Signature.from_callable) as an override which is returned instead of computing the signature through the ordinary process. __text_signature__ serves a...
Open Graph Description: Documentation The __signature__ attribute is treated by inspect.signature (and inspect.Signature.from_callable) as an override which is returned instead of computing the signature through the ordin...
X Description: Documentation The __signature__ attribute is treated by inspect.signature (and inspect.Signature.from_callable) as an override which is returned instead of computing the signature through the ordin...
Opengraph URL: https://github.com/python/cpython/issues/106310
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"__signature__ in the inspect module","articleBody":"# Documentation\r\n\r\nThe `__signature__` attribute is treated by inspect.signature (and inspect.Signature.from_callable) as an override which is returned instead of computing the signature through the ordinary process. `__text_signature__` serves a similar purpose but containing a string version of the signature.\r\nThat's for the implementation.\r\n\r\nNone of the two are mentioned in the signature or Signature sections of the inspect module's doc page. However, the [inspect.unwrap](https://docs.python.org/3/library/inspect.html#inspect.unwrap) function's doc entry mentions, in an example, that inspect.signature does recognize the `__signature__` attribute, without saying what it does with it.\r\nThis is the only mention of `__signature__` or `__text_signature__` in the doc, excluding changelogs, whatsnew, and the Argument clinic section which is overtly implementation-dependent.\r\nHowever, it is also mentioned in the [PEP 362](https://peps.python.org/pep-0362/#implementation) which introduced Signature, albeit in the Implementation section.\r\n\r\nIt should be clarified whether what `__signature__` does is documented or not. It's a very useful feature to be able to cache or lie about a function's signature, and I think it should be supported.\r\nIf not, then inspect.unwrap should stop mentioning it and use another example.\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-106311\r\n* gh-111145\n* gh-111146\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/Gouvernathor","@type":"Person","name":"Gouvernathor"},"datePublished":"2023-07-01T15:20:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/106310/cpython/issues/106310"}
| 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:77a1c7aa-b5a0-fa6b-f2da-de683a860feb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8574:3FFE1:6CBB2A:922B35:6969DA40 |
| html-safe-nonce | 87e3c9549b35b053b9f572b6f724659bf050741fa8553480afb9d76c87d3c304 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTc0OjNGRkUxOjZDQkIyQTo5MjJCMzU6Njk2OURBNDAiLCJ2aXNpdG9yX2lkIjoiODA0NDczNTQwNTE3NDE1MTc0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | aa214324d221d298c1c912a466a754b4e13bd2471580c26a11cab6af47244e8d |
| hovercard-subject-tag | issue:1784010397 |
| 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/106310/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6ab4950a51a592a820931c4a240b47fd51e90d5a48dab581517feb592d0758af/python/cpython/issues/106310 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6ab4950a51a592a820931c4a240b47fd51e90d5a48dab581517feb592d0758af/python/cpython/issues/106310 |
| og:image:alt | Documentation The __signature__ attribute is treated by inspect.signature (and inspect.Signature.from_callable) as an override which is returned instead of computing the signature through the ordin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Gouvernathor |
| 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