Title: Ignoring a file with a single # type: ignore comment. by brandtbucher · Pull Request #6830 · python/mypy · GitHub
Open Graph Title: Ignoring a file with a single # type: ignore comment. by brandtbucher · Pull Request #6830 · python/mypy
X Title: Ignoring a file with a single # type: ignore comment. by brandtbucher · Pull Request #6830 · python/mypy
Description: Fixes #626. For background on the design choices, here is what our current ASTs allow us to find: In all versions of Python, we can accurately detect bare # type: ignore comments before the first statement in a module. In Python 3.8+, we can accurately detect the placement of bare # type: ignore comments within a list of statements (we need end_lineno to do this properly). In no current version of Python can we accurately detect bare # type: ignore comments before the first statement in an indented code block using the AST alone. Considering these limitations, the behavior I chose here is: All versions of Python will ignore a whole file if it contains a bare # type: ignore comment before its first statement. Python 3.8+ will ignore all statements following a bare # type: ignore comment at the top level of a module. This is now a separate PR: #6841. Bare # type: ignore comments have no special meaning inside of indented code blocks. If we were to allow this, we would need to do one of the following (and I personally don't like any of them): Not recognize them at the start of a block. 🙁 Guess where the for/while/with/class/def/try bit ends, a la decorated definitions prior to Python 3.8. 🙁 Parse the raw source of the file ourselves to see where the above block-starters end. 🙁 Modify ast parsing to tell us where the block-starters end. 🙁 A few notes: Ignoring is accomplished by nesting all remaining statements in an unreachable Block. ASTConverter.extra_type_ignores: List[int] is now ASTConverter.type_ignores: Set[int] and is populated before the AST is converted. Tests are added in check-ignore.test and check-38.test.
Open Graph Description: Fixes #626. For background on the design choices, here is what our current ASTs allow us to find: In all versions of Python, we can accurately detect bare # type: ignore comments before the first ...
X Description: Fixes #626. For background on the design choices, here is what our current ASTs allow us to find: In all versions of Python, we can accurately detect bare # type: ignore comments before the first ...
Opengraph URL: https://github.com/python/mypy/pull/6830
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:53e1e527-3c45-9972-2335-02eca0d89958 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B6E8:3C8297:1576A5:1DDA2A:6A583F13 |
| html-safe-nonce | db5a499a465522fd71bafe8be5aa9e7a233e1a5d1881d02170d65b62e5a0d672 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkU4OjNDODI5NzoxNTc2QTU6MUREQTJBOjZBNTgzRjEzIiwidmlzaXRvcl9pZCI6IjY1MzgzNzE4NTQ4NjAwNDIwMDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 32a568e90537cc9e6db15954faa34f9a6d9f7115e7fb4e0eb241fe9888b69db1 |
| hovercard-subject-tag | pull_request:278511633 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/mypy/pull/6830/files |
| twitter:image | https://avatars.githubusercontent.com/u/40968415?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40968415?s=400&v=4 |
| og:image:alt | Fixes #626. For background on the design choices, here is what our current ASTs allow us to find: In all versions of Python, we can accurately detect bare # type: ignore comments before the first ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width