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/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:36d82d26-732a-cf61-2d92-bcc37850ab8e |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | E42E:33C049:7A842A:A59E61:6969DDE4 |
| html-safe-nonce | 55b86453ac2ec37e2889a46a347f5d0fd4d5a6b01060fa0ef28e8706bf4312e0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDJFOjMzQzA0OTo3QTg0MkE6QTU5RTYxOjY5NjlEREU0IiwidmlzaXRvcl9pZCI6IjIzNTAwMDkzNDUwOTc5ODE0MTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 75c44f63e021ec37c6ae472c6bcfa70378aaa7a73329f357232b7153ef5888d6 |
| hovercard-subject-tag | pull_request:1749964975 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,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/checks |
| 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 |
| 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 full-width full-width-p-0 |
| 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