Title: Inferred Union subtype changed inconistently after a failed operation · Issue #3122 · python/mypy · GitHub
Open Graph Title: Inferred Union subtype changed inconistently after a failed operation · Issue #3122 · python/mypy
X Title: Inferred Union subtype changed inconistently after a failed operation · Issue #3122 · python/mypy
Description: (Based on #3111) x: Union[int, str] if isinstance(x, str): reveal_type(x) # Revealed type is 'builtins.str' x = x + 1 # E: Unsupported operand types for + ("str" and "int") reveal_type(x) # Revealed type is 'builtins.int' - CHANGED if is...
Open Graph Description: (Based on #3111) x: Union[int, str] if isinstance(x, str): reveal_type(x) # Revealed type is 'builtins.str' x = x + 1 # E: Unsupported operand types for + ("str" and "int") reveal_type(x) # Reveale...
X Description: (Based on #3111) x: Union[int, str] if isinstance(x, str): reveal_type(x) # Revealed type is 'builtins.str' x = x + 1 # E: Unsupported operand types for + ("str" and "int&quo...
Opengraph URL: https://github.com/python/mypy/issues/3122
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inferred Union subtype changed inconistently after a failed operation","articleBody":"(Based on #3111)\r\n\r\n```\r\nx: Union[int, str]\r\n\r\nif isinstance(x, str):\r\n reveal_type(x) # Revealed type is 'builtins.str'\r\n x = x + 1 # E: Unsupported operand types for + (\"str\" and \"int\")\r\n reveal_type(x) # Revealed type is 'builtins.int' - CHANGED\r\n\r\nif isinstance(x, int):\r\n reveal_type(x) # Revealed type is 'builtins.int'\r\n x = x + 'a' # E: Unsupported operand types for + (\"str\" and \"int\")\r\n reveal_type(x) # Revealed type is 'builtins.int' - DIDN'T CHANGE\r\n```\r\nI'm not sure whether CHANGE or NO CHANGE should be correct, but it should be consistent.\r\n\r\nRelated to this:\r\n\r\n```\r\nx: Union[int, str] = 'a'\r\nx = x + 1 # error\r\nreveal_type(x) # Revealed type: int\r\n```","author":{"url":"https://github.com/pkch","@type":"Person","name":"pkch"},"datePublished":"2017-04-03T22:36:31Z","url":"https://github.com/python/mypy/issues/3122"}
| 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:e18865a9-f19a-b81e-a3b8-61c555fff3f1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C9C:396A8E:2287E06:2DFDF07:6B00582B |
| html-safe-nonce | 3bae1f50348981103884e429c948685850892026db882afd2e05c7051f5ff2b4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzlDOjM5NkE4RToyMjg3RTA2OjJERkRGMDc6NkIwMDU4MkIiLCJ2aXNpdG9yX2lkIjoiMjk5MTA4NTcyMzI5OTU3NDE5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fa037d9a76b21b4220a2167fdae228a99c60dcf51a302e73338306a5fa26b93b |
| hovercard-subject-tag | issue:219081492 |
| 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/3122/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1f0b4cd9d902a87fb67b52a8459fad21d141481f9d4e1d92c64f3633554153ab/python/mypy/issues/3122 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1f0b4cd9d902a87fb67b52a8459fad21d141481f9d4e1d92c64f3633554153ab/python/mypy/issues/3122 |
| og:image:alt | (Based on #3111) x: Union[int, str] if isinstance(x, str): reveal_type(x) # Revealed type is 'builtins.str' x = x + 1 # E: Unsupported operand types for + ("str" and "int") reveal_type(x) # Reveale... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pkch |
| 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