Title: Syntax error in generated stub when using dataclass · Issue #15966 · python/mypy · GitHub
Open Graph Title: Syntax error in generated stub when using dataclass · Issue #15966 · python/mypy
X Title: Syntax error in generated stub when using dataclass · Issue #15966 · python/mypy
Description: Bug Report Stubgen generates an output file with a syntax error. It generates def __mypy-replace which is invalid python syntax because of the dash. To Reproduce With the following python code, generate a stub including the --include-pri...
Open Graph Description: Bug Report Stubgen generates an output file with a syntax error. It generates def __mypy-replace which is invalid python syntax because of the dash. To Reproduce With the following python code, gen...
X Description: Bug Report Stubgen generates an output file with a syntax error. It generates def __mypy-replace which is invalid python syntax because of the dash. To Reproduce With the following python code, gen...
Opengraph URL: https://github.com/python/mypy/issues/15966
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Syntax error in generated stub when using dataclass","articleBody":"\u003c!--\r\nIf you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form instead.\r\nPlease consider:\r\n\r\n- checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html\r\n- searching our issue tracker: https://github.com/python/mypy/issues to see if it's already been reported\r\n- asking on gitter chat: https://gitter.im/python/typing\r\n-->\r\n\r\n**Bug Report**\r\n\r\nStubgen generates an output file with a syntax error.\r\nIt generates `def __mypy-replace` which is invalid python syntax because of the dash. \r\n\r\n**To Reproduce**\r\n\r\nWith the following python code, generate a stub including the `--include-private` flag.\r\n\r\n`stubgen --include-private test.py`\r\n\r\n```python\r\nfrom dataclasses import dataclass\r\n\r\n@dataclass\r\nclass MyDataClass:\r\n foo: str\r\n bar: int\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nThe stub is generated without syntax errors.\r\n\r\n**Actual Behavior**\r\n\r\nA syntax error is raised when parsing the file:\r\n\r\n```\r\n File \"out/test.pyi\", line 5\r\n def __mypy-replace(*, foo, bar) -> None: ...\r\n ^\r\nSyntaxError: invalid syntax\r\n```\r\n\r\nWhen I generate the file without `--include-private` than the stub is generated correctly.\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.5.1\r\n- Python version used: 3.11.4\r\n\r\n**Extra info**\r\n\r\nAlso see https://github.com/KapJI/homeassistant-stubs/issues/349 where this issue was raised.\r\nThese stubs are used in custom Home Assistant components, and currently this is broken.\r\n","author":{"url":"https://github.com/bramstroker","@type":"Person","name":"bramstroker"},"datePublished":"2023-08-26T09:11:02Z","url":"https://github.com/python/mypy/issues/15966"}
| 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:099c57eb-675d-cf9b-6be0-d424e5fef7c7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C83C:6A941:29F71C:35EADA:6AFFC47D |
| html-safe-nonce | a08354dfc98c0ab66d66e8010b515793f5dbae0c014825f20f314e790d05a246 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODNDOjZBOTQxOjI5RjcxQzozNUVBREE6NkFGRkM0N0QiLCJ2aXNpdG9yX2lkIjoiNjg5NDg4MDQzNDIyODgwNjc4MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f395ff6bbf312f1ca515f09043dcd4c52eb686071968cc32c85ad61568f48426 |
| hovercard-subject-tag | issue:1867992900 |
| 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/15966/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e233d4d563bf4b26eafd93199d1bf80a0f5b61b32564285856e1d205dcb900ac/python/mypy/issues/15966 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e233d4d563bf4b26eafd93199d1bf80a0f5b61b32564285856e1d205dcb900ac/python/mypy/issues/15966 |
| og:image:alt | Bug Report Stubgen generates an output file with a syntax error. It generates def __mypy-replace which is invalid python syntax because of the dash. To Reproduce With the following python code, gen... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bramstroker |
| 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