Title: Cannot silence "unused 'type: ignore'" in version specific code · Issue #8823 · python/mypy · GitHub
Open Graph Title: Cannot silence "unused 'type: ignore'" in version specific code · Issue #8823 · python/mypy
X Title: Cannot silence "unused 'type: ignore'" in version specific code · Issue #8823 · python/mypy
Description: I need to execute some code only on specific Python version (it is the use of TextIOWrapper.reconfigure() added in Python 3.7, but in following example I will use more abstract code). import sys if sys.version_info >= (3, 7): x: int = 'a...
Open Graph Description: I need to execute some code only on specific Python version (it is the use of TextIOWrapper.reconfigure() added in Python 3.7, but in following example I will use more abstract code). import sys if...
X Description: I need to execute some code only on specific Python version (it is the use of TextIOWrapper.reconfigure() added in Python 3.7, but in following example I will use more abstract code). import sys if...
Opengraph URL: https://github.com/python/mypy/issues/8823
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot silence \"unused 'type: ignore'\" in version specific code","articleBody":"I need to execute some code only on specific Python version (it is the use of `TextIOWrapper.reconfigure()` added in Python 3.7, but in following example I will use more abstract code).\r\n```python\r\nimport sys\r\n\r\nif sys.version_info >= (3, 7):\r\n x: int = 'a'\r\n```\r\nSince MyPy on Python 3.7 raises an error for it (actually because of the error in `typeshed`) I need to add `# type: ignore`:\r\n```python\r\nimport sys\r\n\r\nif sys.version_info >= (3, 7):\r\n x: int = 'a' # type: ignore\r\n```\r\nBut now I will get an error `unused 'type: ignore' comment` when run MyPy with `warn_unused_ignores = True` on Python 3.6.\r\n\r\nSo I cannot use variant 1, because it is an error on 3.7, and cannot use variant 2, because it is an error on 3.6.\r\n\r\nMyPy should not complain about unused 'type: ignore' comment in the code which it does not analyze.\r\n\r\nMyPy version is 0.770.","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2020-05-14T13:49:25Z","url":"https://github.com/python/mypy/issues/8823"}
| 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:f83ecccd-7b70-caa7-4a70-5a3dd8860082 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B0D2:3F7946:10D3D90:16939E0:6AFFC7C1 |
| html-safe-nonce | 01ca9ad88a7ecc68fc88846524a9688d18a4e8b23699c6e9422cca67ba610ed6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEQyOjNGNzk0NjoxMEQzRDkwOjE2OTM5RTA6NkFGRkM3QzEiLCJ2aXNpdG9yX2lkIjoiNTcwMzk2NzMxMTA3Mzg4ODE5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5aa060173628de4ac09f41a81b7f4981a1629021d64e08dbe8b05429a36354a0 |
| hovercard-subject-tag | issue:618247700 |
| 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/8823/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e746f747058796ffbde5612396afae69e8681584edb27936fa344fbad253b77d/python/mypy/issues/8823 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e746f747058796ffbde5612396afae69e8681584edb27936fa344fbad253b77d/python/mypy/issues/8823 |
| og:image:alt | I need to execute some code only on specific Python version (it is the use of TextIOWrapper.reconfigure() added in Python 3.7, but in following example I will use more abstract code). import sys if... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1e805b832df235bb21305db712c3b6432920019dfc12cb25b9cb8d3b0c9403cf |
| 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 | 8fa4a54e6871c7908eda1c246ad5972982c0b59d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width