Title: What if duck types are unions of all the ducklings · Issue #11516 · python/mypy · GitHub
Open Graph Title: What if duck types are unions of all the ducklings · Issue #11516 · python/mypy
X Title: What if duck types are unions of all the ducklings · Issue #11516 · python/mypy
Description: If the duck typed types were actually unions of all the ducklings then it would fix a bunch of edge cases that arise. And would make this feature more easily understood and discovered. def func1(c: complex): reveal_type(c) # float | int ...
Open Graph Description: If the duck typed types were actually unions of all the ducklings then it would fix a bunch of edge cases that arise. And would make this feature more easily understood and discovered. def func1(c:...
X Description: If the duck typed types were actually unions of all the ducklings then it would fix a bunch of edge cases that arise. And would make this feature more easily understood and discovered. def func1(c:...
Opengraph URL: https://github.com/python/mypy/issues/11516
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"What if duck types are unions of all the ducklings","articleBody":"If the duck typed types were actually unions of all the ducklings then it would fix a bunch of edge cases that arise.\r\nAnd would make this feature more easily understood and discovered.\r\n```py\r\ndef func1(c: complex):\r\n reveal_type(c) # float | int | complex\r\n\r\ndef func2(f: float):\r\n reveal_type(f) # float | int\r\n\r\ndef func3(b: bytes):\r\n reveal_type(b) # bytes | bytearray | memoryview\r\n\r\ndef func4(u: unicode): # python 2 moment\r\n reveal_type(u) # unicode | str\r\n```\r\n\r\nedge cases:\r\n```py\r\ndef func(f: float):\r\n f.is_integer() # error: int has no member \"is_integer\"\r\n```\r\n\r\n```py\r\ndef func(f: float):\r\n if not isinstance(f, float):\r\n print(\"hi\") # no 'unreachable code' error\r\n reveal_type(f) # int | complex\r\n```\r\n\r\nIt would also be useful to have type types for `float` and `bytes`, when you want exactly `float` and don't want any stinking `int`s.\r\n\r\nRelated #11511, #11145","author":{"url":"https://github.com/KotlinIsland","@type":"Person","name":"KotlinIsland"},"datePublished":"2021-11-11T00:15:19Z","url":"https://github.com/python/mypy/issues/11516"}
| 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:c8d0cd20-4826-d2ff-2544-ab2a0557503f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DAA0:2573D7:221ADF8:2E7E1B6:6B002844 |
| html-safe-nonce | dd0e0d1db333e20f584afe00ec2822c4f0d8ef123902a003e84ccf611fa0c6bf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUEwOjI1NzNENzoyMjFBREY4OjJFN0UxQjY6NkIwMDI4NDQiLCJ2aXNpdG9yX2lkIjoiNjAyMzc0OTk2ODY4MDk4NjY5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | da462bced21ff2d2384b0042ff6e02936310dd2f423f0ee7c366fbefb506eecf |
| hovercard-subject-tag | issue:1050445044 |
| 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/11516/issue_layout |
| twitter:image | https://opengraph.githubassets.com/44f341b560a763306749807a55e34532387943c0b22720badddb8cd7de738920/python/mypy/issues/11516 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/44f341b560a763306749807a55e34532387943c0b22720badddb8cd7de738920/python/mypy/issues/11516 |
| og:image:alt | If the duck typed types were actually unions of all the ducklings then it would fix a bunch of edge cases that arise. And would make this feature more easily understood and discovered. def func1(c:... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | KotlinIsland |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width