Title: Type inference of `or` and `Optional[x]` · Issue #1733 · python/mypy · GitHub
Open Graph Title: Type inference of `or` and `Optional[x]` · Issue #1733 · python/mypy
X Title: Type inference of `or` and `Optional[x]` · Issue #1733 · python/mypy
Description: When using --strict-optional, the type of a is incorrectly Union[None, str]: from typing import Optional def f(x: Optional[str]) -> None: a = x or 'default' reveal_type(a) # should be str #1698 seems related.
Open Graph Description: When using --strict-optional, the type of a is incorrectly Union[None, str]: from typing import Optional def f(x: Optional[str]) -> None: a = x or 'default' reveal_type(a) # should be str #1698 see...
X Description: When using --strict-optional, the type of a is incorrectly Union[None, str]: from typing import Optional def f(x: Optional[str]) -> None: a = x or 'default' reveal_type(a) # should be st...
Opengraph URL: https://github.com/python/mypy/issues/1733
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type inference of `or` and `Optional[x]`","articleBody":"When using `--strict-optional`, the type of `a` is incorrectly `Union[None, str]`:\n\n```\nfrom typing import Optional\n\ndef f(x: Optional[str]) -> None:\n a = x or 'default'\n reveal_type(a) # should be str\n```\n#1698 seems related.\n","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2016-06-22T10:59:12Z","url":"https://github.com/python/mypy/issues/1733"}
| 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:e803d4ae-7e3b-687b-67c8-7b2bb6f2827c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1FC:5537E:19685D3:218C4F1:6B00209C |
| html-safe-nonce | dc2bacfc701f90e9a6b92cc92889f4b2dc3d4b09a469a3823a0f606724e2401f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUZDOjU1MzdFOjE5Njg1RDM6MjE4QzRGMTo2QjAwMjA5QyIsInZpc2l0b3JfaWQiOiI2Mzg2Njg0NzI5NjQ2NjUzNTk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 949a8d719eae5ec14794e3e4557b35e9dc54a587c19657366f390681bfd3543e |
| hovercard-subject-tag | issue:161651864 |
| 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/1733/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4c154f9f3d2319956be6c54bb2c18b0b0e725e3e34c9e94c6af447d865f8b7de/python/mypy/issues/1733 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4c154f9f3d2319956be6c54bb2c18b0b0e725e3e34c9e94c6af447d865f8b7de/python/mypy/issues/1733 |
| og:image:alt | When using --strict-optional, the type of a is incorrectly Union[None, str]: from typing import Optional def f(x: Optional[str]) -> None: a = x or 'default' reveal_type(a) # should be str #1698 see... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JukkaL |
| 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