Title: Else block of `isinstance` check with promotable types has
Open Graph Title: Else block of `isinstance` check with promotable types has
X Title: Else block of `isinstance` check with promotable types has
Description: This test case from typing import Union def asdf(val: Union[int, float]): if isinstance(val, float): reveal_type(val) else: reveal_type(val) produces: /home/msullivan/lol2.py:4: error: Revealed type is 'builtins.float' /home/msullivan/lo...
Open Graph Description: This test case from typing import Union def asdf(val: Union[int, float]): if isinstance(val, float): reveal_type(val) else: reveal_type(val) produces: /home/msullivan/lol2.py:4: error: Revealed typ...
X Description: This test case from typing import Union def asdf(val: Union[int, float]): if isinstance(val, float): reveal_type(val) else: reveal_type(val) produces: /home/msullivan/lol2.py:4: error: Revealed typ...
Opengraph URL: https://github.com/python/mypy/issues/6141
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Else block of `isinstance` check with promotable types has \u003cnothing> for type","articleBody":"This test case\r\n```\r\nfrom typing import Union\r\ndef asdf(val: Union[int, float]):\r\n if isinstance(val, float):\r\n reveal_type(val)\r\n else:\r\n reveal_type(val)\r\n```\r\nproduces:\r\n```\r\n/home/msullivan/lol2.py:4: error: Revealed type is 'builtins.float'\r\n/home/msullivan/lol2.py:6: error: Revealed type is '\u003cnothing>'\r\n```\r\nBut the type in the `else` branch ought to be `int`.\r\n\r\nPrior to #6114, it produced\r\n```\r\n/home/msullivan/lol2.py:4: error: Revealed type is 'Union[builtins.int, builtins.float]'\r\n```\r\nwhich is of course also wrong.\r\nThe prior version produced false positives in the then branch and false negatives in the else branch, while the new version produces false positives in the else branch and works correctly in the then branch.","author":{"url":"https://github.com/msullivan","@type":"Person","name":"msullivan"},"datePublished":"2019-01-04T21:48:15Z","url":"https://github.com/python/mypy/issues/6141"}
| 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:d7d6d27b-76e0-32f2-bbe6-768d77fdca93 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 86C6:245A38:DCD42A:12974BC:6B005801 |
| html-safe-nonce | b0d5207a86a077e7f679e037029edf204d93061929ca757d793fd23cdfef17bc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NkM2OjI0NUEzODpEQ0Q0MkE6MTI5NzRCQzo2QjAwNTgwMSIsInZpc2l0b3JfaWQiOiI1ODEzODYxMDI0MzY4OTczODI1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 83b2a0b71ae491fca118dc299ea4122d08b2c5e5b41f9876afc66fbc230fe916 |
| hovercard-subject-tag | issue:396078940 |
| 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/6141/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ad998f9fc85637946bc5e22b4c4953290a7df72cae11f4e7576e88ece95356f7/python/mypy/issues/6141 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ad998f9fc85637946bc5e22b4c4953290a7df72cae11f4e7576e88ece95356f7/python/mypy/issues/6141 |
| og:image:alt | This test case from typing import Union def asdf(val: Union[int, float]): if isinstance(val, float): reveal_type(val) else: reveal_type(val) produces: /home/msullivan/lol2.py:4: error: Revealed typ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | msullivan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73 |
| 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 | eacd927ba6112e3b01ba99c762bd699a4a4f5df7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width