Title: Re-document __signature__ as a feature by Gouvernathor · Pull Request #116124 · python/cpython · GitHub
Open Graph Title: Re-document __signature__ as a feature by Gouvernathor · Pull Request #116124 · python/cpython
X Title: Re-document __signature__ as a feature by Gouvernathor · Pull Request #116124 · python/cpython
Description: This seeks to re-resolve #106310, and improve #116086 in resolving #115937. The original pull request for #106310, #106311, documented the behavior as the original PEP362 described it : any object found in __signature__ and not None would be returned by inspect.signature. But in fact, since 2014 apparently, a type guard allowing only instances of Signature to pass, or else raise an exception. The documentation was in fact inaccurate as a result. Other changes to the inspect.signature function occurred through #100039 where it gained implementation-detail support for strings and callables to be set as __signature__, something which I'm trying to roll back. Regardless, the latest change to the documentation which sought to address the discrepancies between the doc and the implementation, #115937, demoted the Signature-in-__signature__ behavior from a feature to a vague implementation detail. My proposition is to document things the following way: Signature objects in __signature__ are returned as-is by the inspect.signature function None is ignored and the behavior is as if __signature__ was not set Behavior for any other value is an implementation detail. That way, uses of __signature__ as a cache or as a way to hide undocumented parameters remains guaranteed, while allowing the strings and callables support to be decided and to evolve separately. I kept the "consult the source code for current semantics" line in an effort to limit changes to a minimum, but I would be in favor of removing it. 📚 Documentation preview 📚: https://cpython-previews--116124.org.readthedocs.build/
Open Graph Description: This seeks to re-resolve #106310, and improve #116086 in resolving #115937. The original pull request for #106310, #106311, documented the behavior as the original PEP362 described it : any object ...
X Description: This seeks to re-resolve #106310, and improve #116086 in resolving #115937. The original pull request for #106310, #106311, documented the behavior as the original PEP362 described it : any object ...
Opengraph URL: https://github.com/python/cpython/pull/116124
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c85b15f7-3989-9d52-b261-87336562efcb |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DAD2:34CBCC:5B7428:7AE67C:6969DC9A |
| html-safe-nonce | b793fa027a68514fbd35c4040f65c479ada311680376b081a743275f62feaac2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUQyOjM0Q0JDQzo1Qjc0Mjg6N0FFNjdDOjY5NjlEQzlBIiwidmlzaXRvcl9pZCI6Ijc1MzYwOTA0MjU1Mzc5Nzc0OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5c442856081a19bb4b9abec39be59befc953d702aea42ebda3aca4684a981c11 |
| hovercard-subject-tag | pull_request:1749964975 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/116124/files |
| twitter:image | https://avatars.githubusercontent.com/u/44340603?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/44340603?s=400&v=4 |
| og:image:alt | This seeks to re-resolve #106310, and improve #116086 in resolving #115937. The original pull request for #106310, #106311, documented the behavior as the original PEP362 described it : any object ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 | true |
| 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