Skip to content

Match obsolete comparison diagnostics - #9074

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix-obsolete-comparison-diagnostic
Draft

youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix-obsolete-comparison-diagnostic

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Current status

Current head: dd0c42ff332013dff6584e896e70638176008307, targeting main. The current source uses Python 3.15.0, not the older 3.14.8 pin described by earlier revisions. Exact-head hosted checks are complete: 27 succeeded and one conditional benchmark check was skipped; CI succeeded. The prior CI-pause and intermediate-head descriptions are superseded.

This remains a draft because the parser-versus-compiler architecture question is still open. A passing CI run and the token-overlap correction do not settle that design decision.

Scope

  • Emit the obsolete-comparison hint for infix 2 <> 3, with the complete operator span.
  • Keep bare <> a generic syntax error and preserve Barry-mode behavior.
  • Match adjacent, complete < and > tokens rather than a textual substring, so 2 <<> 3 does not incorrectly match the suffix of <<.
  • Keep the Python-visible message/span coverage in the existing extra_tests/snippets/builtin_compile.py, including overlap controls. Existing Rust tests retain structural parsing checks.

Only crates/compiler/src/lib.rs and that existing snippet change. No Lib/ files or parser dependency are changed. The source still uses registry rustpython-ruff_python_parser 0.16.10.

Remaining architecture question

The current implementation lives in the existing compiler BarrySource adapter. It inspects parser tokens and the first parse-error position, then returns its diagnostic before first_parse_error in the compiler and symbol-table paths. This fixes the documented textual-token overlap, but still infers comparison context outside the parser.

A parser-owned diagnostic would let the grammar's comparison production determine context directly. Such a migration would also need to remove or narrow the compiler override so it does not replace the parser's diagnostic. No parser migration is claimed by this patch; maintainer review of that boundary remains necessary.

Validation and history

Exact-head hosted CI is the current validation evidence. This status refresh adds no code and claims no new local runtime or build execution.

The earlier 3.14.8 backport/source-extraction revisions had focused ASCII diagnostic, compiler and Barry-mode checks, normal hooks and scoped Clippy. Those results belong to their historical revisions, not a fresh run of this head. The change originated from the CPython obsolete-operator diagnostic update 66f8dbe0.

AI assistance

Maintainer-requested Python compatibility maintenance. OpenAI Codex assisted with source analysis, code and validation work in the existing commits, and this status/review clarification. Model version unavailable. No additional human manual testing is claimed by this update.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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.

if let Some(error) = parse_error
&& let Some(range) = self.invalid_legacy_operator(error)
{
if error.location.start() > range.start() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the right place instead of patching parser?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser is the cleaner place for this diagnostic. I used the existing BarrySource adapter to keep the extraction independent of a parser release, but the review uncovered a real weakness: for 2 <<> 3, the textual match overlaps the << token and incorrectly emits the obsolete-comparison hint. I confirmed that with compile-only CPython 3.14.8/native checks. A comparison-context check in the pinned parser is the appropriate fix; the compiler override must also stop replacing that parser diagnostic. I am checking the narrow dependency path rather than importing the broader parser changes. This draft is not ready in its current form.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser is still the cleaner owner of this grammar-context diagnostic. The current head, dd0c42f, fixes the concrete 2 <<> 3 overlap by matching complete adjacent tokens instead of searching the source text, and its exact-head CI passes. That does not resolve your architecture question.

The implementation still lives in BarrySource::diagnostic: it combines the token range with the parser's first error location, and the compiler/symbol-table paths call it before first_parse_error. The registry Ruff parser remains at 0.16.10. Moving the diagnostic into the comparison production would therefore also require removing or narrowing this compiler override, so the adapter does not replace the parser's result.

I've corrected the stale PR description and kept this boundary explicit. The PR remains a draft pending that design decision; I haven't made an unrelated parser rewrite. This clarification is AI-assisted with OpenAI Codex (model version unavailable), based on the current source and hosted results.

@youknowdot
youknowdot force-pushed the fix-obsolete-comparison-diagnostic branch from 5b0fac6 to 7b25dc1 Compare October 11, 2026 03:17
@youknowdot youknowdot changed the title Match Python 3.14.8 obsolete comparison diagnostics Match obsolete comparison diagnostics Oct 11, 2026
@youknowdot
youknowdot force-pushed the fix-obsolete-comparison-diagnostic branch from 7b25dc1 to 1c36965 Compare October 11, 2026 03:21
@youknowone
youknowone changed the base branch from main to stack/python-3.15-8950 October 11, 2026 03:26
@youknowdot
youknowdot force-pushed the fix-obsolete-comparison-diagnostic branch from 1c36965 to 0596dee Compare October 11, 2026 04:07
@youknowone
youknowone changed the base branch from stack/python-3.15-8950 to main October 11, 2026 04:09
@youknowdot
youknowdot force-pushed the fix-obsolete-comparison-diagnostic branch from 0596dee to aa02e48 Compare October 11, 2026 04:14
@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[ ] test: cpython/Lib/test/test_mmap.py (TODO: 19)

dependencies:

dependent tests: (2 tests)

  • mmap: test_os
    • multiprocessing.shared_memory: test_genericalias

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

Use the existing Barry adapter token spans for ordinary obsolete-comparison diagnostics as well. Preserve parser errors for left-shift suffixes, malformed comparisons, comments and strings, with final Python 3.15 message and span regressions.

Assisted-by: OpenAI Codex:model identifier unavailable
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.

2 participants