Title: Type of conditional expression is object · Issue #8074 · python/mypy · GitHub
Open Graph Title: Type of conditional expression is object · Issue #8074 · python/mypy
X Title: Type of conditional expression is object · Issue #8074 · python/mypy
Description: The type of the following conditional expression is object: s: str = "key=value" a, b = s.split("=", 1) if "=" in s else ("key", "default") # main.py:2: error: 'builtins.object' object is not iterable It should be a union type instead, s...
Open Graph Description: The type of the following conditional expression is object: s: str = "key=value" a, b = s.split("=", 1) if "=" in s else ("key", "default") # main.py:2: error: 'builtins.object' object is not itera...
X Description: The type of the following conditional expression is object: s: str = "key=value" a, b = s.split("=", 1) if "=" in s else ("key", "default") # main....
Opengraph URL: https://github.com/python/mypy/issues/8074
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type of conditional expression is object","articleBody":"The type of the following conditional expression is `object`:\r\n\r\n```\r\ns: str = \"key=value\"\r\na, b = s.split(\"=\", 1) if \"=\" in s else (\"key\", \"default\")\r\n# main.py:2: error: 'builtins.object' object is not iterable\r\n```\r\n\r\nIt should be a union type instead, such as `Union[List[str], Tuple[str, str]]`.\r\n\r\n(Note that `str.split` returns `List[str]` while the `else` branch has the type `Tuple[str, str]`.)\r\n\r\n- [Gist](https://gist.github.com/4d8ef543c0a86d6966fa5722c792e345)\r\n- [Playground](https://mypy-play.net/?mypy=latest&python=3.8&gist=4d8ef543c0a86d6966fa5722c792e345)\r\n\r\nThis is a follow-up to https://github.com/python/mypy/issues/3487.\r\n","author":{"url":"https://github.com/cjolowicz","@type":"Person","name":"cjolowicz"},"datePublished":"2019-12-04T16:08:12Z","url":"https://github.com/python/mypy/issues/8074"}
| 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:ad60e622-28ea-c948-e2cc-0a666dfa8c2a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D1F6:2714DE:23C3FF3:306FCF7:6B002702 |
| html-safe-nonce | 14dc82ca7f998335a3a8c427cf9dcea24a27a3d428c771cf7e83322a32716cf9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMUY2OjI3MTRERToyM0MzRkYzOjMwNkZDRjc6NkIwMDI3MDIiLCJ2aXNpdG9yX2lkIjoiNzUzODMwMDE3MzM1MzQ5NDI3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e795516545dd918f973e6f5fdbc6dcb13317b642dacbb94d11c077bf401b796f |
| hovercard-subject-tag | issue:532783475 |
| 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/8074/issue_layout |
| twitter:image | https://opengraph.githubassets.com/302787e46c68d5aadbc46ba844dfdd425be27ab7daf67849e115b09eb719cc17/python/mypy/issues/8074 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/302787e46c68d5aadbc46ba844dfdd425be27ab7daf67849e115b09eb719cc17/python/mypy/issues/8074 |
| og:image:alt | The type of the following conditional expression is object: s: str = "key=value" a, b = s.split("=", 1) if "=" in s else ("key", "default") # main.py:2: error: 'builtins.object' object is not itera... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cjolowicz |
| 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