Title: Use abstract types from `numbers` · Issue #7217 · python/typeshed · GitHub
Open Graph Title: Use abstract types from `numbers` · Issue #7217 · python/typeshed
X Title: Use abstract types from `numbers` · Issue #7217 · python/typeshed
Description: Right now types declared in numbers.pyi are not used. This causes this problem: from numbers import Real def test(f: Real) -> Real: return f test(1.32) # error: Argument 1 to "test" has incompatible type "float"; expected "Real" But, in ...
Open Graph Description: Right now types declared in numbers.pyi are not used. This causes this problem: from numbers import Real def test(f: Real) -> Real: return f test(1.32) # error: Argument 1 to "test" has incompatibl...
X Description: Right now types declared in numbers.pyi are not used. This causes this problem: from numbers import Real def test(f: Real) -> Real: return f test(1.32) # error: Argument 1 to "test" ha...
Opengraph URL: https://github.com/python/typeshed/issues/7217
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use abstract types from `numbers`","articleBody":"Right now types declared in [`numbers.pyi`](https://github.com/python/typeshed/blob/master/stdlib/numbers.pyi) are not used.\r\nThis causes this problem:\r\n\r\n```python\r\nfrom numbers import Real\r\n\r\ndef test(f: Real) -> Real:\r\n return f\r\n\r\ntest(1.32)\r\n# error: Argument 1 to \"test\" has incompatible type \"float\"; expected \"Real\"\r\n```\r\n\r\nBut, in runtime:\r\n- `float` is registered to be `Real`, source: https://github.com/python/cpython/blob/12360aa159c42c7798fd14225d271e6fd84db7eb/Lib/numbers.py#L264\r\nAlso:\r\n- `complex`: https://github.com/python/cpython/blob/12360aa159c42c7798fd14225d271e6fd84db7eb/Lib/numbers.py#L144\r\n- `int`: https://github.com/python/cpython/blob/12360aa159c42c7798fd14225d271e6fd84db7eb/Lib/numbers.py#L393\r\n\r\nBut, how can we type it? Options:\r\n1. Use a base class in `builtins.pyi`\r\n2. Use `Real.register(float)` in `builtins.pyi`\r\n3. Use `Real.register(float)` in `numbers.pyi` (as runtime does)","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2022-02-15T05:56:08Z","url":"https://github.com/python/typeshed/issues/7217"}
| 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:15ae2468-4da4-c1ac-bc6f-8e90655f16c8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D9B6:D064:202ED78:2B9E2F1:6B001A1A |
| html-safe-nonce | dd3912beb1eec8d435e5edae8f73572a2794b61c6633ba74ef5b7c93760574ad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUI2OkQwNjQ6MjAyRUQ3ODoyQjlFMkYxOjZCMDAxQTFBIiwidmlzaXRvcl9pZCI6IjU1ODEzOTMxNDA2MjkxMTc0NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bb5bfc43288cf60aafae49060f8cab16f938cbb22f65c715582357a9ee76ee2e |
| hovercard-subject-tag | issue:1138219586 |
| 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/7217/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f535e0bcac7b19019015dcbba09d546a9b87eb7c7e7fe4720cfa25b02f57772b/python/typeshed/issues/7217 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f535e0bcac7b19019015dcbba09d546a9b87eb7c7e7fe4720cfa25b02f57772b/python/typeshed/issues/7217 |
| og:image:alt | Right now types declared in numbers.pyi are not used. This causes this problem: from numbers import Real def test(f: Real) -> Real: return f test(1.32) # error: Argument 1 to "test" has incompatibl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| 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