Title: Collapse bare ExpectedExpression to 'invalid syntax'; fix '<>' diagnostic offset by mumallaeng · Pull Request #8540 · RustPython/RustPython · GitHub
Open Graph Title: Collapse bare ExpectedExpression to 'invalid syntax'; fix '<>' diagnostic offset by mumallaeng · Pull Request #8540 · RustPython/RustPython
X Title: Collapse bare ExpectedExpression to 'invalid syntax'; fix '<>' diagnostic offset by mumallaeng · Pull Request #8540 · RustPython/RustPython
Description: Closes #xxxx This PR follows our AI policy AI disclosure This PR was implemented by Claude Code (Anthropic, Claude Sonnet 5), driven interactively by a human maintainer of a downstream RustPython consumer (Pyre) across a full session: the human directed the investigation, reviewed and steered each step, and made the call to open this PR. The commit carries an Assisted-by: Claude Code:claude-sonnet-5 trailer per policy. The change itself is small and self-contained (~30 lines in one function), and has been exercised against CPython's test_flufl.py via the downstream consumer mentioned below, plus a spot-check regression pass over test_grammar, test_syntax, test_tokenize, and test_compile showing no behavior change outside the two fixed cases. Summary ParseErrorType::ExpectedExpression currently surfaces as the raw ruff parser message (e.g. "Expected an expression") to callers that only depend on rustpython-compiler (no rustpython-vm). rustpython-vm's vm_new.rs already collapses this to CPython's generic "invalid syntax" for its own callers; this mirrors that same collapse inside cpython_parse_diagnostic_override so non-vm consumers get the same CPython-compatible message. A bare <> outside Barry-as-BDFL mode (2 <> 3) lexes as Less then an unexpected Greater, so the resulting ExpectedExpression location points at the > — one character past where CPython's tokenizer (which treats <> as a single obsolete token) reports the error. Detect the < immediately preceding the location and shift the reported range back over it. This is a companion to a RustPython/ruff PR implementing real Barry-as-BDFL tokenizer support, which needs the offset fix here to make CPython's test_flufl.py pass end to end. It's independently useful for any caller hitting these two message/offset mismatches outside Barry mode too. Test plan Reproduced against CPython's Lib/test/test_flufl.py (via a downstream consumer, Pyre) — test_guido_as_bdfl and test_barry_as_bdfl_relative_import now pass with correct message text and offset. cargo check -p rustpython-compiler passes. Summary by CodeRabbit Bug Fixes Improved syntax error messages for obsolete <> usage. Standardized certain parser errors as “invalid syntax.” Adjusted error locations so diagnostics highlight the correct source text.
Open Graph Description: Closes #xxxx This PR follows our AI policy AI disclosure This PR was implemented by Claude Code (Anthropic, Claude Sonnet 5), driven interactively by a human maintainer of a downstream RustPython...
X Description: Closes #xxxx This PR follows our AI policy AI disclosure This PR was implemented by Claude Code (Anthropic, Claude Sonnet 5), driven interactively by a human maintainer of a downstream RustPython...
Opengraph URL: https://github.com/RustPython/RustPython/pull/8540
X: @github
Domain: github.com
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:2e9cb0f7-9c39-d6a3-65a2-251853e13bc9 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A568:3F7946:2353C28:3027897:6B00311D |
| html-safe-nonce | 56aa3c849ad32696cee806d4d91d204fd79e1f57e943ab38eaa21aceafb604bc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTY4OjNGNzk0NjoyMzUzQzI4OjMwMjc4OTc6NkIwMDMxMUQiLCJ2aXNpdG9yX2lkIjoiMTA0NjE0OTY0MTYyNTY3ODExMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 19f330e0fee94cbc9b65ecc0e14485e6c50af8ff6ba6087a7931f968e5838c0f |
| hovercard-subject-tag | pull_request:4294103752 |
| 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/RustPython/RustPython/pull/8540/files |
| twitter:image | https://avatars.githubusercontent.com/u/83155697?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/83155697?s=400&v=4 |
| og:image:alt | Closes #xxxx This PR follows our AI policy AI disclosure This PR was implemented by Claude Code (Anthropic, Claude Sonnet 5), driven interactively by a human maintainer of a downstream RustPython... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width