Title: `pow` `NoReturn` overload is used by Pyright and Pyre when argument types are not known · Issue #8566 · python/typeshed · GitHub
Open Graph Title: `pow` `NoReturn` overload is used by Pyright and Pyre when argument types are not known · Issue #8566 · python/typeshed
X Title: `pow` `NoReturn` overload is used by Pyright and Pyre when argument types are not known · Issue #8566 · python/typeshed
Description: The first overload of pow currently looks like this: @overload def pow(base: int, exp: int, mod: Literal[0]) -> NoReturn: ... When the argument types are not known, Pyright and Pyre use the first overload -- the NoReturn overload. Here's...
Open Graph Description: The first overload of pow currently looks like this: @overload def pow(base: int, exp: int, mod: Literal[0]) -> NoReturn: ... When the argument types are not known, Pyright and Pyre use the first o...
X Description: The first overload of pow currently looks like this: @overload def pow(base: int, exp: int, mod: Literal[0]) -> NoReturn: ... When the argument types are not known, Pyright and Pyre use the firs...
Opengraph URL: https://github.com/python/typeshed/issues/8566
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`pow` `NoReturn` overload is used by Pyright and Pyre when argument types are not known","articleBody":"The first overload of `pow` currently looks like this:\r\n\r\n```python\r\n@overload\r\ndef pow(base: int, exp: int, mod: Literal[0]) -> NoReturn: ...\r\n```\r\n\r\nWhen the argument types are not known, Pyright and [Pyre](https://pyre-check.org/play?input=def%20RSAcompute(message%2C%20exponent%2C%20pubkey)%3A%0A%20%20%20%20data%20%3D%20pow(message%2C%20exponent%2C%20pubkey)%0A%20%20%20%20reveal_type(data)%0A%20%20%20%20return%20data%0A%0Aprint(%22OK%20start%22)%0Ares%20%3D%20RSAcompute(12%2C%2034%2C%2056)%0Aprint(%22Now%20pylance%20says%20unreachable%22)) use the first overload -- the `NoReturn` overload. \r\n\r\nHere's an example from https://github.com/microsoft/pylance-release/issues/3214:\r\n\r\n```python\r\ndef RSAcompute(message, exponent, pubkey):\r\n data = pow(message, exponent, pubkey)\r\n # The rest of the function is marked as unreachable\r\n # because Pyright/Pylance see pow's return type as NoReturn\r\n toto = 42\r\n return data\r\n\r\nres = RSAcompute(12, 34, 56)\r\nprint(\"Similarly this line is considered unreachable\")\r\n```\r\n\r\n@AlexWaygood, it looks like you added the `NoReturn` overload [here](https://github.com/python/typeshed/pull/6287/files#diff-1580ddf7dc331234b0845ffb953b6f7a5f1e9afa15048ebc0762226a08f194b4R1281). Does it actually help users? I'm wondering if it could be removed, or at least moved down in the overload ordering so Pyright and Pyre would behave better in this situation.","author":{"url":"https://github.com/debonte","@type":"Person","name":"debonte"},"datePublished":"2022-08-19T00:58:28Z","url":"https://github.com/python/typeshed/issues/8566"}
| 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:19b2bdfa-1eb3-70d1-44e2-b9112d817e2c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E91C:2463C6:29761:389A0:6B0019EC |
| html-safe-nonce | 6d2692dd9cce9e3d1537410c513b1faccc6afa1fee8eddcf081a2bc58ddf4b5d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTFDOjI0NjNDNjoyOTc2MTozODlBMDo2QjAwMTlFQyIsInZpc2l0b3JfaWQiOiIyOTYyNjU5MTc4MzMxNTExMjc3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1f86dab5ecbb737eb1fe507b1ecea6b21041f6c3f321137594793d4d353ccad4 |
| hovercard-subject-tag | issue:1343797861 |
| 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/8566/issue_layout |
| twitter:image | https://opengraph.githubassets.com/18fe157378594d3710de6d4d7a2fe8cbaed5b2d725a3436f526ee394501f54f9/python/typeshed/issues/8566 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/18fe157378594d3710de6d4d7a2fe8cbaed5b2d725a3436f526ee394501f54f9/python/typeshed/issues/8566 |
| og:image:alt | The first overload of pow currently looks like this: @overload def pow(base: int, exp: int, mod: Literal[0]) -> NoReturn: ... When the argument types are not known, Pyright and Pyre use the first o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | debonte |
| 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