Title: Make any callable compatible with (*args: Any, **kwargs: Any)? · Issue #5876 · python/mypy · GitHub
Open Graph Title: Make any callable compatible with (*args: Any, **kwargs: Any)? · Issue #5876 · python/mypy
X Title: Make any callable compatible with (*args: Any, **kwargs: Any)? · Issue #5876 · python/mypy
Description: Perhaps a callable that accepts arbitrary arguments by having (*args: Any, **kwargs: Any) could be treated similarly to Callable[..., X] (with explicit ...), i.e. a callable with arbitrary arguments would be compatible with it. The reaso...
Open Graph Description: Perhaps a callable that accepts arbitrary arguments by having (*args: Any, **kwargs: Any) could be treated similarly to Callable[..., X] (with explicit ...), i.e. a callable with arbitrary argument...
X Description: Perhaps a callable that accepts arbitrary arguments by having (*args: Any, **kwargs: Any) could be treated similarly to Callable[..., X] (with explicit ...), i.e. a callable with arbitrary argument...
Opengraph URL: https://github.com/python/mypy/issues/5876
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make any callable compatible with (*args: Any, **kwargs: Any)?","articleBody":"Perhaps a callable that accepts arbitrary arguments by having `(*args: Any, **kwargs: Any)` could be treated similarly to `Callable[..., X]` (with explicit `...`), i.e. a callable with arbitrary arguments would be compatible with it.\r\n\r\nThe reason for this is that there's no easy way to annotate a function so that the type would be `Callable[..., X]`, even though this seems to be a somewhat common need. Users sometimes assume that using `(*args: Any, **kwargs: Any)` will work for this purpose and are confused when it doesn't. https://github.com/python/typing/issues/264#issuecomment-436525286 is a recent example.\r\n\r\nExample:\r\n\r\n```py\r\nfrom typing import Any\r\n\r\nclass A:\r\n # A method that accepts unspecified arguments and returns int\r\n def f(self, *args: Any, **kwargs: Any) -> int: pass\r\n\r\nclass B(A):\r\n def f(self, x: int) -> int: pass # Should be okay\r\n```\r\n\r\nWe could perhaps extend this to handle decorators as well:\r\n\r\n```py\r\nfrom typing import Any, Callable, TypeVar\r\n\r\nT = TypeVar('T', bound=Callable[..., Any])\r\n\r\ndef deco(f: T) -> T:\r\n def wrapper(*args: Any, **kwargs: Any) -> Any:\r\n print('called')\r\n return f(*args, **kwargs)\r\n return wrapper # Maybe this should be okay\r\n```","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2018-11-08T18:29:09Z","url":"https://github.com/python/mypy/issues/5876"}
| 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:076f9d8a-51f5-f237-3d29-9317796d7c55 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BBAC:14A3EB:E76942:12C750A:6AFFEFD6 |
| html-safe-nonce | 5e9dec64ecc0a7d7a49430bbb23107c2bc6faedbb75418c77ad4376e3a9879d9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkFDOjE0QTNFQjpFNzY5NDI6MTJDNzUwQTo2QUZGRUZENiIsInZpc2l0b3JfaWQiOiI1ODY3MjE5ODA3MjQ1MzkzNTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 80147d3a401ee62053e7af9debc4779b9ffddb1ac229b0187ed01d606ca8d569 |
| hovercard-subject-tag | issue:378861180 |
| 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/mypy/5876/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9286e2a19c192e79e537b342c269158f18d74459bf00f70339e6056fd3f856e7/python/mypy/issues/5876 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9286e2a19c192e79e537b342c269158f18d74459bf00f70339e6056fd3f856e7/python/mypy/issues/5876 |
| og:image:alt | Perhaps a callable that accepts arbitrary arguments by having (*args: Any, **kwargs: Any) could be treated similarly to Callable[..., X] (with explicit ...), i.e. a callable with arbitrary argument... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JukkaL |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width