Title: Unhelpful `SyntaxError` with unclosed call before colon · Issue #94034 · python/cpython · GitHub
Open Graph Title: Unhelpful `SyntaxError` with unclosed call before colon · Issue #94034 · python/cpython
X Title: Unhelpful `SyntaxError` with unclosed call before colon · Issue #94034 · python/cpython
Description: Ran into this today. If you forget to close parentheses as part of a call in the header of a for, with, or class statement (maybe others too?), the SyntaxError seems to indicate that you forgot a colon: >>> for foo in bar(baz: File " Open Graph Description: Ran into this today. If you forget to close parentheses as part of a call in the header of a for, with, or class statement (maybe others too?), the SyntaxError seems to indicate that you forgot a c...
X Description: Ran into this today. If you forget to close parentheses as part of a call in the header of a for, with, or class statement (maybe others too?), the SyntaxError seems to indicate that you forgot a c...
Opengraph URL: https://github.com/python/cpython/issues/94034
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unhelpful `SyntaxError` with unclosed call before colon","articleBody":"Ran into this today. If you forget to close parentheses as part of a call in the header of a `for`, `with`, or `class` statement (maybe others too?), the `SyntaxError` seems to indicate that you forgot a colon:\r\n\r\n```py\r\n\u003e\u003e\u003e for foo in bar(baz:\r\n File \"\u003cstdin\u003e\", line 1\r\n for foo in bar(baz:\r\n ^\r\nSyntaxError: expected ':'\r\n```\r\n\r\nIt's not *wrong*, but could probably be improved. I personally find the pre-3.10 behavior more helpful:\r\n\r\n```py\r\n\u003e\u003e\u003e bar(baz:\r\n File \"\u003cstdin\u003e\", line 1\r\n for foo in bar(baz:\r\n ^\r\nSyntaxError: invalid syntax\r\n```\r\n\r\nEven better, though, would be a \"smarter\" error message like the existing ones we have for unclosed parentheses:\r\n\r\n```py\r\n\u003e\u003e\u003e bar(baz:\r\n File \"\u003cstdin\u003e\", line 1\r\n for foo in bar(baz:\r\n ^\r\nSyntaxError: '(' was never closed\r\n```\r\n\r\n@pablogsal","author":{"url":"https://github.com/brandtbucher","@type":"Person","name":"brandtbucher"},"datePublished":"2022-06-20T17:32:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/94034/cpython/issues/94034"}
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:e4ccfd4e-620e-f29e-d792-ffe6df19d81f current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id A570:291671:3C6A84:528D92:6969DB91 html-safe-nonce 3d7795d1119828211927e27f55408bb20868500c5adbbb0979337f7ce0a930ea visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTcwOjI5MTY3MTozQzZBODQ6NTI4RDkyOjY5NjlEQjkxIiwidmlzaXRvcl9pZCI6IjYzNTIyNzkyNDk4NTAzMjU5MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== visitor-hmac aae8abfad4b3b4b958a821b5fd3c2f2b350126c236bdf93e8e30780da3eaa6de hovercard-subject-tag issue:1277215098 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/cpython/94034/issue_layout twitter:image https://opengraph.githubassets.com/72aaeb020573258dba1fa26e2c443b1390469deec8e3e43608a1b5ad73fe5dbb/python/cpython/issues/94034 twitter:card summary_large_image og:image https://opengraph.githubassets.com/72aaeb020573258dba1fa26e2c443b1390469deec8e3e43608a1b5ad73fe5dbb/python/cpython/issues/94034 og:image:alt Ran into this today. If you forget to close parentheses as part of a call in the header of a for, with, or class statement (maybe others too?), the SyntaxError seems to indicate that you forgot a c... og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username brandtbucher hostname github.com expected-hostname github.com None 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 turbo-cache-control no-preview go-import github.com/python/cpython git https://github.com/python/cpython.git octolytics-dimension-user_id 1525981 octolytics-dimension-user_login python octolytics-dimension-repository_id 81598961 octolytics-dimension-repository_nwo python/cpython octolytics-dimension-repository_public true octolytics-dimension-repository_is_fork false octolytics-dimension-repository_network_root_id 81598961 octolytics-dimension-repository_network_root_nwo python/cpython 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 bdde15ad1b403e23b08bbd89b53fbe6bdf688cad ui-target full theme-color #1e2327 color-scheme light dark
URLs of crawlers that visited me.