Title: isinstance(x, (t1, t2)) doesn't change mypy's knowledge of x's type. · Issue #1328 · python/mypy · GitHub
Open Graph Title: isinstance(x, (t1, t2)) doesn't change mypy's knowledge of x's type. · Issue #1328 · python/mypy
X Title: isinstance(x, (t1, t2)) doesn't change mypy's knowledge of x's type. · Issue #1328 · python/mypy
Description: For example in the following code: def f(x): # type: (object) -> list if isinstance(x, (list, set)): return [g(i) for i in x] mypy will complain that an Iterable is expected (it still only sees x as an object). This can be resolved with ...
Open Graph Description: For example in the following code: def f(x): # type: (object) -> list if isinstance(x, (list, set)): return [g(i) for i in x] mypy will complain that an Iterable is expected (it still only sees x a...
X Description: For example in the following code: def f(x): # type: (object) -> list if isinstance(x, (list, set)): return [g(i) for i in x] mypy will complain that an Iterable is expected (it still only sees ...
Opengraph URL: https://github.com/python/mypy/issues/1328
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"isinstance(x, (t1, t2)) doesn't change mypy's knowledge of x's type.","articleBody":"For example in the following code:\n\n```\ndef f(x):\n # type: (object) -> list\n if isinstance(x, (list, set)):\n return [g(i) for i in x]\n```\n\nmypy will complain that an `Iterable` is expected (it still only sees `x` as an `object`). This can be resolved with e.g. a manual `cast` of `x` to `Union[list, set]`, but this adds a slight overhead and isn't as clean.\n","author":{"url":"https://github.com/nathanielherman","@type":"Person","name":"nathanielherman"},"datePublished":"2016-04-05T02:08:42Z","url":"https://github.com/python/mypy/issues/1328"}
| 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:fb266e00-5485-452b-396e-2a68cd6f3ee8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BDE2:2C0A92:3068E57:3FE7258:6B002956 |
| html-safe-nonce | dd4ebb9141af0915cc3d2e4e279af941c0d92fdd2a9ceb41fc5c4d7d10946690 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREUyOjJDMEE5MjozMDY4RTU3OjNGRTcyNTg6NkIwMDI5NTYiLCJ2aXNpdG9yX2lkIjoiNzY4NzYwNjQzMzk3MzY0MDU0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c5ea92741cf28fcbae6d669d4210a1dd9d1bd4980348045934b8d3de5ff1691e |
| hovercard-subject-tag | issue:145862333 |
| 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/1328/issue_layout |
| twitter:image | https://opengraph.githubassets.com/58f54e676408654cf9321bee7a7941a1edb0a41343454c02fdbb44f3a5e473bd/python/mypy/issues/1328 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/58f54e676408654cf9321bee7a7941a1edb0a41343454c02fdbb44f3a5e473bd/python/mypy/issues/1328 |
| og:image:alt | For example in the following code: def f(x): # type: (object) -> list if isinstance(x, (list, set)): return [g(i) for i in x] mypy will complain that an Iterable is expected (it still only sees x a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nathanielherman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width