Title: @functools.cache destroys the function signature · Issue #11280 · python/typeshed · GitHub
Open Graph Title: @functools.cache destroys the function signature · Issue #11280 · python/typeshed
X Title: @functools.cache destroys the function signature · Issue #11280 · python/typeshed
Description: A function decorated with @functools.cache loses its signature: @functools.cache def my_func(foo: int | list) -> str: return str(foo) my_func('completely', 'incorrect', 'arguments') # Success: no issues found in 1 source file There is an...
Open Graph Description: A function decorated with @functools.cache loses its signature: @functools.cache def my_func(foo: int | list) -> str: return str(foo) my_func('completely', 'incorrect', 'arguments') # Success: no i...
X Description: A function decorated with @functools.cache loses its signature: @functools.cache def my_func(foo: int | list) -> str: return str(foo) my_func('completely', 'incorrect', 'argu...
Opengraph URL: https://github.com/python/typeshed/issues/11280
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@functools.cache destroys the function signature","articleBody":"A function decorated with `@functools.cache` loses its signature:\r\n\r\n```python\r\n@functools.cache\r\ndef my_func(foo: int | list) -> str:\r\n return str(foo)\r\n\r\nmy_func('completely', 'incorrect', 'arguments')\r\n# Success: no issues found in 1 source file\r\n```\r\n\r\nThere *is* an error if you try to pass an argument that isn't hashable:\r\n\r\n```python\r\nmy_func([])\r\n# error: Argument 1 to \"__call__\" of \"_lru_cache_wrapper\" has\r\n# incompatible type \"list[Never]\"; expected \"Hashable\" [arg-type]\r\n```\r\n\r\nBut this completely ruins Intellisense:\r\n\r\n\r\n\r\nI understand that the type system isn't powerful enough to express the correct semantics, which would be this:\r\n\r\n```python\r\n@functools.cache\r\ndef my_func(foo: int | list) -> str:\r\n return str(foo)\r\n\r\nreveal_type(my_func) # Callable[[int], str]\r\n```\r\n\r\nThat said, I would much rather have functioning Intellisense than a warning about unhashable inputs.","author":{"url":"https://github.com/Aran-Fey","@type":"Person","name":"Aran-Fey"},"datePublished":"2024-01-16T17:12:51Z","url":"https://github.com/python/typeshed/issues/11280"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:c39314d9-e9f8-d9a8-e20d-e05b245f53c7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 97EC:2A4B31:2B4E7:3A906:6B0019F3 |
| html-safe-nonce | e95079e10cfe6f96516d56d5dcd03d80389456c9e69d2d044dc74708dbe6be68 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0VDOjJBNEIzMToyQjRFNzozQTkwNjo2QjAwMTlGMyIsInZpc2l0b3JfaWQiOiI1MTQ4MjMxODM3NTU3OTg3ODI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c0d8164dffaee0934179f19365179e2caee3e6b4c8195e1f4861a7e58abfc4f0 |
| hovercard-subject-tag | issue:2084464702 |
| 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/typeshed/11280/issue_layout |
| twitter:image | https://opengraph.githubassets.com/caa1b7c94185b4f936cd34853ea3b9dc80f2fdc4d055dfd2559f4ecd6aed6a8a/python/typeshed/issues/11280 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/caa1b7c94185b4f936cd34853ea3b9dc80f2fdc4d055dfd2559f4ecd6aed6a8a/python/typeshed/issues/11280 |
| og:image:alt | A function decorated with @functools.cache loses its signature: @functools.cache def my_func(foo: int | list) -> str: return str(foo) my_func('completely', 'incorrect', 'arguments') # Success: no i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Aran-Fey |
| hostname | github.com |
| expected-hostname | github.com |
| None | a2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | 70121d4e855ee0bb7b75cf15d061d91f8863c0f8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width