Title: Platform check is not remembered after `return` · Issue #14940 · python/mypy · GitHub
Open Graph Title: Platform check is not remembered after `return` · Issue #14940 · python/mypy
X Title: Platform check is not remembered after `return` · Issue #14940 · python/mypy
Description: Bug Report A platform check that is working fine in if and else is not working after if ... return. To Reproduce import sys def works() -> None: if sys.platform != "win32": return else: from winreg import REG_SZ def fails() -> None: if s...
Open Graph Description: Bug Report A platform check that is working fine in if and else is not working after if ... return. To Reproduce import sys def works() -> None: if sys.platform != "win32": return else: from winreg...
X Description: Bug Report A platform check that is working fine in if and else is not working after if ... return. To Reproduce import sys def works() -> None: if sys.platform != "win32": return else...
Opengraph URL: https://github.com/python/mypy/issues/14940
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Platform check is not remembered after `return`","articleBody":"**Bug Report**\r\n\r\nA platform check that is working fine in `if` and `else` is not working after `if ... return`.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nimport sys\r\n\r\ndef works() -\u003e None:\r\n if sys.platform != \"win32\":\r\n return\r\n else:\r\n from winreg import REG_SZ\r\n\r\ndef fails() -\u003e None:\r\n if sys.platform != \"win32\":\r\n return\r\n from winreg import REG_SZ\r\n```\r\n\r\nhttps://mypy-play.net/?mypy=latest\u0026python=3.11\u0026gist=eddad091a6082bd85c5c7524839726b1\r\n\r\n**Expected Behavior**\r\n\r\nNo error.\r\n\r\n**Actual Behavior**\r\n\r\nmain.py:12: error: Module \"winreg\" has no attribute \"REG_SZ\" [attr-defined]\r\nFound 1 error in 1 file (checked 1 source file)\r\n\r\n**Your Environment**\r\n\r\n- Failure is on Linux\r\n- Mypy version used: 1.1.1\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.11.2\r\n","author":{"url":"https://github.com/bersbersbers","@type":"Person","name":"bersbersbers"},"datePublished":"2023-03-23T02:55:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/14940/mypy/issues/14940"}
| 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:fe3479ae-f4d9-3d9d-1e44-3b02d6f71ac0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E136:15461D:1A20EA7:2305730:6A598179 |
| html-safe-nonce | 07d7a7212fba4255a56666298e74413e75c3ec29e3ae43cca6b260aa4aa488a8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTM2OjE1NDYxRDoxQTIwRUE3OjIzMDU3MzA6NkE1OTgxNzkiLCJ2aXNpdG9yX2lkIjoiNDIzMTg3MDE0Nzk4NzA3OTU0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 16c278c2d7e34641413ea727f63709163d2c03e6f5e55b51795f3c7a6a1a3d9a |
| hovercard-subject-tag | issue:1636767978 |
| 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/14940/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7065bb3b914437e7b74cd1a568e049510b3317f33bf1a4827f4fda5c54bc52a1/python/mypy/issues/14940 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7065bb3b914437e7b74cd1a568e049510b3317f33bf1a4827f4fda5c54bc52a1/python/mypy/issues/14940 |
| og:image:alt | Bug Report A platform check that is working fine in if and else is not working after if ... return. To Reproduce import sys def works() -> None: if sys.platform != "win32": return else: from winreg... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bersbersbers |
| hostname | github.com |
| expected-hostname | github.com |
| None | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| 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 | 624bb50a7497aa346bef8cc3743af408a9ea10ca |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width