Title: Type inference with 'not isinstance' checks · Issue #476 · python/mypy · GitHub
Open Graph Title: Type inference with 'not isinstance' checks · Issue #476 · python/mypy
X Title: Type inference with 'not isinstance' checks · Issue #476 · python/mypy
Description: Code like this currently fails but should be okay: def f(x: Union[int, str]) -> None: if not isinstance(x, int): return x + 2 # x must be int here so this is okay, but mypy complains Note that this works currently (without the not operat...
Open Graph Description: Code like this currently fails but should be okay: def f(x: Union[int, str]) -> None: if not isinstance(x, int): return x + 2 # x must be int here so this is okay, but mypy complains Note that this...
X Description: Code like this currently fails but should be okay: def f(x: Union[int, str]) -> None: if not isinstance(x, int): return x + 2 # x must be int here so this is okay, but mypy complains Note that t...
Opengraph URL: https://github.com/python/mypy/issues/476
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type inference with 'not isinstance' checks","articleBody":"Code like this currently fails but should be okay:\n\n``` python\ndef f(x: Union[int, str]) -> None:\n if not isinstance(x, int):\n return\n x + 2 # x must be int here so this is okay, but mypy complains\n```\n\nNote that this works currently (without the `not` operator):\n\n``` python\ndef f(x: Union[int, str]) -> None:\n if isinstance(x, str):\n return\n x + 2 # this is considered valid, as it should be\n```\n","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2014-10-12T18:15:31Z","url":"https://github.com/python/mypy/issues/476"}
| 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:5f8add28-3cec-8de3-ee35-bfe6c23b286b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 87E0:1A77D:298898:37C4FE:6B0024BB |
| html-safe-nonce | 51f650c6533c5502657e16827a9d955fb81b2ef5245d1175e41a71e57e924533 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0UwOjFBNzdEOjI5ODg5ODozN0M0RkU6NkIwMDI0QkIiLCJ2aXNpdG9yX2lkIjoiNTMwOTE3ODE0Nzc2ODM3ODU1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 06232f453aa35126d405618ad8fc44e88b4f2aff667044ab424d10e263f7f531 |
| hovercard-subject-tag | issue:45588519 |
| 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/476/issue_layout |
| twitter:image | https://opengraph.githubassets.com/668f90f41e1da11d9b777ccb3065748ad78a5dcdfb6cd9bca1eafce5774e2f56/python/mypy/issues/476 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/668f90f41e1da11d9b777ccb3065748ad78a5dcdfb6cd9bca1eafce5774e2f56/python/mypy/issues/476 |
| og:image:alt | Code like this currently fails but should be okay: def f(x: Union[int, str]) -> None: if not isinstance(x, int): return x + 2 # x must be int here so this is okay, but mypy complains Note that this... |
| 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