Title: Stugben: Handling files with file encoding comment · Issue #3726 · python/mypy · GitHub
Open Graph Title: Stugben: Handling files with file encoding comment · Issue #3726 · python/mypy
X Title: Stugben: Handling files with file encoding comment · Issue #3726 · python/mypy
Description: I was trying to generate stubs for sre_compile and it fails with: $ python stubgen.py --py2 sre_compile .../2.7/lib/python2.7/sre_compile.py:0: error: encoding declaration in Unicode string This is probably happening because ast27_parse_...
Open Graph Description: I was trying to generate stubs for sre_compile and it fails with: $ python stubgen.py --py2 sre_compile .../2.7/lib/python2.7/sre_compile.py:0: error: encoding declaration in Unicode string This is...
X Description: I was trying to generate stubs for sre_compile and it fails with: $ python stubgen.py --py2 sre_compile .../2.7/lib/python2.7/sre_compile.py:0: error: encoding declaration in Unicode string This is...
Opengraph URL: https://github.com/python/mypy/issues/3726
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stugben: Handling files with file encoding comment","articleBody":"I was trying to generate stubs for [`sre_compile`](https://hg.python.org/cpython/file/2.7/Lib/sre_compile.py) and it fails with:\r\n\r\n```\r\n$ python stubgen.py --py2 sre_compile\r\n.../2.7/lib/python2.7/sre_compile.py:0: error: encoding declaration in Unicode string\r\n```\r\n\r\nThis is probably happening because [`ast27_parse_impl `](https://github.com/python/typed_ast/blob/f4495f45d1d456aae7d01da9f9670fe01e974f17/ast27/Custom/typed_ast.c#L259) converts source from bytes to string and tries to parse it without caring about source code encoding comment.\r\n\r\nPEP 263 says:\r\n\r\n> If a Unicode string with a coding declaration is passed to `compile()` , a `SyntaxError` will be raised.\r\n\r\nOne quick fix would be to remove such comment from source before it is passed to [`mypy.parse.parse()` in stubgen.py](https://github.com/python/mypy/blob/master/mypy/stubgen.py#L202).\r\n\r\nI am wondering if this is worth fixing? If yes, is the above the best way to do it.","author":{"url":"https://github.com/ashwch","@type":"Person","name":"ashwch"},"datePublished":"2017-07-17T20:48:51Z","url":"https://github.com/python/mypy/issues/3726"}
| 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:a188b71b-dad2-608a-c76e-07200d464ffd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9CC8:3F6072:1E5363:2ACDA0:6B005764 |
| html-safe-nonce | e496d593d85a666f6e81984f9c25d257236aa7e89ea5375bc934e3c5771343c9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Q0M4OjNGNjA3MjoxRTUzNjM6MkFDREEwOjZCMDA1NzY0IiwidmlzaXRvcl9pZCI6Ijg3MjE5MzAxNjQ4MjI1Njc0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fd6a7f0c2fa8d36ffe75e7827176392d639bf0523f4959e5e5c1f2e8939dd8e3 |
| hovercard-subject-tag | issue:243522929 |
| 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/3726/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c7a6974710d0e1296975cd7bcf43e2525f5c7d92364085ffb8c846083e366fb8/python/mypy/issues/3726 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c7a6974710d0e1296975cd7bcf43e2525f5c7d92364085ffb8c846083e366fb8/python/mypy/issues/3726 |
| og:image:alt | I was trying to generate stubs for sre_compile and it fails with: $ python stubgen.py --py2 sre_compile .../2.7/lib/python2.7/sre_compile.py:0: error: encoding declaration in Unicode string This is... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ashwch |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width