Title: None-ness falsely assumed in loop · Issue #11430 · python/mypy · GitHub
Open Graph Title: None-ness falsely assumed in loop · Issue #11430 · python/mypy
X Title: None-ness falsely assumed in loop · Issue #11430 · python/mypy
Description: Bug Report After foo = None, mypy thinks that foo will always be None, even if a loop can jump between the assignment and the use of foo. To Reproduce def main() -> None: gonna_select = None while True: if gonna_select is not None: print...
Open Graph Description: Bug Report After foo = None, mypy thinks that foo will always be None, even if a loop can jump between the assignment and the use of foo. To Reproduce def main() -> None: gonna_select = None while ...
X Description: Bug Report After foo = None, mypy thinks that foo will always be None, even if a loop can jump between the assignment and the use of foo. To Reproduce def main() -> None: gonna_select = None whi...
Opengraph URL: https://github.com/python/mypy/issues/11430
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"None-ness falsely assumed in loop","articleBody":"**Bug Report**\r\n\r\nAfter `foo = None`, mypy thinks that `foo` will always be `None`, even if a loop can jump between the assignment and the use of `foo`.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\ndef main() -\u003e None:\r\n gonna_select = None\r\n while True:\r\n if gonna_select is not None:\r\n print(1 + \"lol\")\r\n gonna_select = \"lol\"\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nerror from `1 + \"lol\"`\r\n\r\n**Actual Behavior**\r\n\r\nno error\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 0.910\r\n- Mypy command-line flags: none\r\n- Mypy configuration options from `mypy.ini` (and other config files): none\r\n- Python version used: 3.7","author":{"url":"https://github.com/Akuli","@type":"Person","name":"Akuli"},"datePublished":"2021-11-01T22:14:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/11430/mypy/issues/11430"}
| 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:74b306f0-ebd4-f364-803d-58762d2a42e7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5BC:23B29E:474069:5E2FBD:6A5B8CAB |
| html-safe-nonce | 0ec6407f2ef7408cfe802f35db3b1abc4b6936c73ffab6f1b2aca3fe2da2a705 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUJDOjIzQjI5RTo0NzQwNjk6NUUyRkJEOjZBNUI4Q0FCIiwidmlzaXRvcl9pZCI6IjIwMTI2MTA0MDI0MDA4MzI2ODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6a45e3cf7a7cbc9cd460193d3d93e4f6311dab88d671561ec7fb3c0acecb96c4 |
| hovercard-subject-tag | issue:1041690272 |
| 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/11430/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5e76af92ecd1ae077e58f72b4533cf06ffd053db26db6af0cd0fcf448098d742/python/mypy/issues/11430 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5e76af92ecd1ae077e58f72b4533cf06ffd053db26db6af0cd0fcf448098d742/python/mypy/issues/11430 |
| og:image:alt | Bug Report After foo = None, mypy thinks that foo will always be None, even if a loop can jump between the assignment and the use of foo. To Reproduce def main() -> None: gonna_select = None while ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Akuli |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width