Skip to content

Fix check for error groups that appear on a single line - #2386

Merged
srittau merged 1 commit into
python:mainfrom
RaphaelFakhri:conformance-single-line-group-check
Nov 5, 2026
Merged

srittau merged 1 commit into
python:mainfrom
RaphaelFakhri:conformance-single-line-group-check

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

get_expected_errors() in conformance/src/main.py is meant to reject a # E[tag] group that appears on only one line, as conformance/README.md documents ("must appear multiple times in a file with the same tag"). The check never runs, because each value in groups is a (linenos, multiplicity) tuple. len() of that tuple is always 2, so len(linenos) == 1 is never true.

As a result, a mistyped tag (for example # E[final] on one line and # E[fianl] on the other) silently turns one "error on exactly one of these lines" group into two single-line groups. Each of them then requires an error on its own line, and a type checker that behaves correctly is scored as failing.

This change unpacks the tuple so the check compares the number of lines. It also updates the docstring example, which still showed the old bool value instead of ErrorMultiplicity.SINGLE.

Testing

  • With a file that contains # E[typo] on one line and # E[good] on two lines, get_expected_errors() now raises ValueError: Error group typo only appears on a single line in .... Before the change it returned without an error.
  • Every file in conformance/tests still passes through get_expected_errors() without errors (156 files), so no existing test needs changes and no results change.

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@srittau srittau added the topic: conformance tests Issues with the conformance test suite label Nov 5, 2026
@srittau
srittau merged commit 871c2f0 into python:main Nov 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: conformance tests Issues with the conformance test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants