Title: type refinement in function call · Issue #5206 · python/mypy · GitHub
Open Graph Title: type refinement in function call · Issue #5206 · python/mypy
X Title: type refinement in function call · Issue #5206 · python/mypy
Description: This is ok for mypy: from typing import Union def foo(x: Union[int, str]): if isinstance(x, int): return x + 10 but how can I make it work if the isinstance test is in a function call? from typing import Union def check(x: Union[int, str...
Open Graph Description: This is ok for mypy: from typing import Union def foo(x: Union[int, str]): if isinstance(x, int): return x + 10 but how can I make it work if the isinstance test is in a function call? from typing ...
X Description: This is ok for mypy: from typing import Union def foo(x: Union[int, str]): if isinstance(x, int): return x + 10 but how can I make it work if the isinstance test is in a function call? from typing ...
Opengraph URL: https://github.com/python/mypy/issues/5206
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"type refinement in function call","articleBody":"This is ok for mypy:\r\n\r\n```\r\nfrom typing import Union\r\n\r\ndef foo(x: Union[int, str]):\r\n if isinstance(x, int):\r\n return x + 10\r\n```\r\n\r\nbut how can I make it work if the `isinstance` test is in a function call?\r\n\r\n```\r\nfrom typing import Union\r\n\r\ndef check(x: Union[int, str]) -> bool:\r\n return isinstance(x, int)\r\n\r\ndef foo(x: Union[int, str]):\r\n if check(x):\r\n return x + 10\r\n```\r\n\r\nI get:\r\n\r\n```\r\nfoo.py:8: error: Unsupported operand types for + (\"Union[int, str]\" and \"int\")\r\n```","author":{"url":"https://github.com/dfroger","@type":"Person","name":"dfroger"},"datePublished":"2018-06-12T14:32:51Z","url":"https://github.com/python/mypy/issues/5206"}
| 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:3cd52070-eeab-a80d-1473-7ea3aba95e33 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B420:1BAA33:1403678:1A63812:6B000C69 |
| html-safe-nonce | f6e771dd1cbef026d1254b563eb2e64a5ea38655417bc163f2cd3f1e374ea37e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDIwOjFCQUEzMzoxNDAzNjc4OjFBNjM4MTI6NkIwMDBDNjkiLCJ2aXNpdG9yX2lkIjoiNjY5MjI1NzIwNDQ4NzA2NDY4MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 48fb87e9110f2e00d90cd1745943e4890d80209654d0d04b00da867524e66200 |
| hovercard-subject-tag | issue:331614734 |
| 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/5206/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d9e19f02b5dd24c04d682a051db192d9f208154ad28c0030c7caf489db48156e/python/mypy/issues/5206 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d9e19f02b5dd24c04d682a051db192d9f208154ad28c0030c7caf489db48156e/python/mypy/issues/5206 |
| og:image:alt | This is ok for mypy: from typing import Union def foo(x: Union[int, str]): if isinstance(x, int): return x + 10 but how can I make it work if the isinstance test is in a function call? from typing ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dfroger |
| 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