Skip to content

Use the Ruff fork 0.17.1 for CPython syntax error messages and the obsolete '<>' hint - #9212

Merged
youknowone merged 2 commits into
RustPython:mainfrom
youknowone:ruff-0.17.1-syntax-errors
Oct 20, 2026
Merged

youknowone merged 2 commits into
RustPython:mainfrom
youknowone:ruff-0.17.1-syntax-errors

Conversation

@youknowone

@youknowone youknowone commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

  • The ruff crates come from the RustPython/ruff rustpython-0.17.1 branch by git rev, not from crates.io. That branch is ruff 0.17.1 with the RustPython fork patches on top. The crates are not published yet.
  • Fork changes used here:
    • A forced : after def/try/finally/else reports "expected ':'".
    • raise from / raise x from report the did you forget an expression ... messages.
    • Empty del/global/nonlocal, async + other token, decorator without definition, missing module or as name, and with without items report "invalid syntax".
    • The import and with trailing comma messages are added.
    • An adjacent < > in a comparison reports "invalid syntax. Maybe you meant '!=' instead of '<>'?" (invalid_noteq).
  • The compiler places an error on the token made up at the end of the input according to the error kind (EofErrorLocation). The keyword scan that guessed forced tokens is removed.
  • Outside Barry mode, BarrySource no longer searches the source text for <>. The parser's error is used unchanged, so 2 <<> 3 is no longer matched. This covers the parser-owned approach discussed in Match obsolete comparison diagnostics #9074.

Testing

  • cargo clippy --workspace --all-targets (with the usual excludes): no new warnings.
  • cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi
  • (cd crates/capi && cargo test)
  • rustpython -m test --dont-add-python-opts: 37 modules passed, including test_syntax, test_codeop, test_repl, test_grammar, test_exceptions, test_compile, test_ast, test_tokenize, test_eof and test_flufl.

AI assistance

Written with Claude Code (claude-opus-5-5).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved the locations shown for syntax errors at the end of a file, including errors involving missing tokens, empty imports, and invalid syntax.
    • Empty-import diagnostics now retain the parser’s reported range.
    • Improved guidance for the obsolete <> operator, with clearer error spans and a “Maybe you meant” hint for comparisons.
    • Legacy <> handling is now limited to Barry mode.

…kind

- The ruff crates come from the RustPython/ruff `rustpython-0.17.1`
  branch at 93967836c8 instead of the 0.16.10 crates.io release.
- `EofToken.known_location` is replaced by `EofErrorLocation`
  (Tokenizer, Token, StartingFromToken), chosen from the parse error kind.
  The keyword scan in `clause_keyword` is removed, since the parser now
  reports a forced `:` as `ExpectedForcedToken`.
- An empty import at EOF ends at the end of the line read, and an empty
  import before a newline is an empty range at the newline.

Assisted-by: Claude Code:claude-opus-5-5
- Bump the RustPython/ruff fork to 9290a88495, where the parser reports an
  adjacent `<` and `>` in a comparison as "invalid syntax.  Maybe you meant
  '!=' instead of '<>'?" over both tokens.
- Outside Barry mode, `BarrySource` no longer searches the source text for
  `<>`, so the parser's error is reported unchanged. A `<>` that starts a
  statement is reported at the `<` only, and `<<>` at the `>`.

Assisted-by: Claude Code:claude-opus-5-5
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T11:59:24.970231Z 24e2b77 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4f3f63b3-ff5a-4b8e-a12b-7fd9845145fd
📥 Commits

Reviewing files that changed from the base of the PR and between 5235a89 and 24e2b77.

⛔ Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing: 2
  • Cargo.toml
  • crates/compiler/src/lib.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The compiler changes EOF error location classification and parse-diagnostic spans. It also changes how legacy <> operators are recorded and diagnosed. Four Ruff dependencies now use a pinned RustPython fork revision.

Changes: Parser diagnostics

Layer / File(s) Summary
EOF diagnostic locations
Cargo.toml, crates/compiler/src/lib.rs
The compiler classifies EOF errors as tokenizer-positioned, token-positioned, or spanning from the token to the tokenizer stop. EmptyImportNames retains the parser’s original locations. Four Ruff dependencies now resolve from a pinned RustPython fork revision.
Legacy not-equal operator handling
crates/compiler/src/lib.rs
The compiler records legacy <> operators only in Barry mode. Updated tests cover the comparison hint and spans for bare <> and 2 <<> 3.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: youknowdot

Merge Risk: ⚪ Minimal · up to 24e2b

No actionable issue remains identified in the dependency or parser-diagnostic changes; the PR is mergeable after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately summarizes the main changes: adopting the RustPython Ruff fork for CPython syntax error messages and updating the obsolete "<>" hint behavior.
Docstring Coverage Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 1 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 1 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@youknowone
youknowone merged commit cdb5cca into RustPython:main Oct 20, 2026
30 checks passed
@youknowone
youknowone deleted the ruff-0.17.1-syntax-errors branch October 20, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant