Title: NoReturn return type with singledispatch causing weird errors · Issue #11727 · python/mypy · GitHub
Open Graph Title: NoReturn return type with singledispatch causing weird errors · Issue #11727 · python/mypy
X Title: NoReturn return type with singledispatch causing weird errors · Issue #11727 · python/mypy
Description: [This was originally in a comment by @Dreamsorcerer] ... This issue has mostly talked about the redefinition error. But, we should also have singledispatch typing working. e.g. With this example: @singledispatch def foo(data: object) -> ...
Open Graph Description: [This was originally in a comment by @Dreamsorcerer] ... This issue has mostly talked about the redefinition error. But, we should also have singledispatch typing working. e.g. With this example: @...
X Description: [This was originally in a comment by @Dreamsorcerer] ... This issue has mostly talked about the redefinition error. But, we should also have singledispatch typing working. e.g. With this example: @...
Opengraph URL: https://github.com/python/mypy/issues/11727
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NoReturn return type with singledispatch causing weird errors","articleBody":"[This was originally in a [comment](https://github.com/python/mypy/issues/2904#issuecomment-946973563) by @Dreamsorcerer]\r\n\r\n...\r\n\r\nThis issue has mostly talked about the redefinition error. But, we should also have singledispatch typing working. e.g. With this example:\r\n\r\n```py\r\n@singledispatch\r\ndef foo(data: object) -> NoReturn:\r\n raise ValueError(f\"Unhandled type {type(data)}\")\r\n@foo.register\r\ndef _(data: str) -> str:\r\n return data\r\n@foo.register\r\ndef _(data: int) -> str:\r\n return str(data)\r\n\r\na = foo(7)\r\nreveal_type(a)\r\n```\r\n\r\nYou also get errors due to not recognising the overloads:\r\n\r\n```\r\nsrc/service/transaction_status_service.py:72: error: Need type annotation for \"a\" [var-annotated]\r\nsrc/service/transaction_status_service.py:73: note: Revealed type is \"\u003cnothing>\"\r\n```\r\n\r\nIt would be good for mypy to treat the `@foo.register` like an `@overload`.\r\n\r\nI was also getting unreachable code errors after every call to the defined function. However, I was unable to reproduce it with a minimal example, so not sure exactly what is causing that.","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2021-12-13T18:33:48Z","url":"https://github.com/python/mypy/issues/11727"}
| 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:b6c43acb-c042-c446-9db7-a87b549fcd2f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED72:1E3154:6156C3:828AB6:6B0033ED |
| html-safe-nonce | b83aee19d745f2e8ca05d68fa24645565123ea2d70e96284015e7cc663e127da |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDcyOjFFMzE1NDo2MTU2QzM6ODI4QUI2OjZCMDAzM0VEIiwidmlzaXRvcl9pZCI6IjI1NDQ3NTQxODIxODgwNDIwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c1a2d1e1b3146d1850057742ef72444239de06d873717f129630affaa6033f98 |
| hovercard-subject-tag | issue:1078853273 |
| 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/11727/issue_layout |
| twitter:image | https://opengraph.githubassets.com/28082dbbd330a9822ebde8d124f93f77cf6fe6a9f43fa146504abc791918ad9d/python/mypy/issues/11727 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/28082dbbd330a9822ebde8d124f93f77cf6fe6a9f43fa146504abc791918ad9d/python/mypy/issues/11727 |
| og:image:alt | [This was originally in a comment by @Dreamsorcerer] ... This issue has mostly talked about the redefinition error. But, we should also have singledispatch typing working. e.g. With this example: @... |
| 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 | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width