Title: Types not added to binder on initial assignment · Issue #2008 · python/mypy · GitHub
Open Graph Title: Types not added to binder on initial assignment · Issue #2008 · python/mypy
X Title: Types not added to binder on initial assignment · Issue #2008 · python/mypy
Description: from typing import Union x = 0 # type: Union[int, str] reveal_type(x) # Revealed type is 'Union[builtins.int, builtins.str]' x = 0 reveal_type(x) # Revealed type is 'builtins.int' This means if you want to declare a union and then immedi...
Open Graph Description: from typing import Union x = 0 # type: Union[int, str] reveal_type(x) # Revealed type is 'Union[builtins.int, builtins.str]' x = 0 reveal_type(x) # Revealed type is 'builtins.int' This means if you...
X Description: from typing import Union x = 0 # type: Union[int, str] reveal_type(x) # Revealed type is 'Union[builtins.int, builtins.str]' x = 0 reveal_type(x) # Revealed type is 'builtins.int' T...
Opengraph URL: https://github.com/python/mypy/issues/2008
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Types not added to binder on initial assignment","articleBody":"``` py\nfrom typing import Union\nx = 0 # type: Union[int, str]\nreveal_type(x) # Revealed type is 'Union[builtins.int, builtins.str]'\nx = 0\nreveal_type(x) # Revealed type is 'builtins.int'\n```\n\nThis means if you want to declare a union and then immediately use it as one specific member, you'll have an awkward time. For example:\n\n``` py\nx = \"foo\" # type: Optional[str]\nx + \"bar\" # E: Unsupported operand types for + (\"Union[str, None]\" and \"str\")\n```\n\nTo be consistent with other assignments, we should add types to the binder on initial assignment. I think a number of Union/Optional tests depend on the current behavior, so those will need to be updated.\n","author":{"url":"https://github.com/ddfisher","@type":"Person","name":"ddfisher"},"datePublished":"2016-08-10T00:41:43Z","url":"https://github.com/python/mypy/issues/2008"}
| 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:92e3b036-9d73-3ca7-20e5-3fe7bf44dd5e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C7C4:390AA2:1A31F69:235DE4D:6AFFFB10 |
| html-safe-nonce | cefc4022b7d4f42cd8f5fda7cf2ff251b1005deabe1685b23b4de763464b75a2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDN0M0OjM5MEFBMjoxQTMxRjY5OjIzNURFNEQ6NkFGRkZCMTAiLCJ2aXNpdG9yX2lkIjoiOTE4MTI2MzQxMDQ4MDgwNjY3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4525b3e4db28ec556f0f65c749550f83c8827664bca49706f29a3a1679133652 |
| hovercard-subject-tag | issue:170303630 |
| 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/2008/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ed0dceeeab61ab46630617aa5e780482c7bcbf87032526557448177b9d50d657/python/mypy/issues/2008 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ed0dceeeab61ab46630617aa5e780482c7bcbf87032526557448177b9d50d657/python/mypy/issues/2008 |
| og:image:alt | from typing import Union x = 0 # type: Union[int, str] reveal_type(x) # Revealed type is 'Union[builtins.int, builtins.str]' x = 0 reveal_type(x) # Revealed type is 'builtins.int' This means if you... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ddfisher |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width