Skip to content

Report parse errors as file:line:column#5237

Open
wanxiankai wants to merge 2 commits into
psf:mainfrom
wanxiankai:feat/parse-error-location
Open

Report parse errors as file:line:column#5237
wanxiankai wants to merge 2 commits into
psf:mainfrom
wanxiankai:feat/parse-error-location

Conversation

@wanxiankai

@wanxiankai wanxiankai commented Jul 14, 2026

Copy link
Copy Markdown

Description

Fixes #3157.

Parser failures currently reach the CLI as a string, so the report prefix separates the file path from the line and column (cannot format path: Cannot parse: line:column). This prevents editors and problem matchers from recognizing a standard source location.

This change keeps structured context, line, column, and diagnostic details on InvalidInput while preserving its existing string representation for API consumers such as blackd. CLI reports now render parser failures as error: cannot parse: path:line:column, while non-parser failures retain the existing cannot format output. The structured attributes are also covered by a pickle round trip because multi-file formatting passes exceptions back from worker processes.

Checklist - did you ...

  • Implement any code style changes under the --preview style, following the stability policy? (No code style change.)
  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation? (No documentation change is needed for this error-output fix.)

Test results

  • 471 passed, 3 skipped, 8 subtests passed
  • pre-commit: isort, flake8, mypy, end-of-file, trailing-whitespace, and changelog checks passed

@github-actions

Copy link
Copy Markdown
Contributor

diff-shades results comparing this PR (b2e6d24) to main (51abf53):

--preview style: no changes

--stable style: no changes


What is this? | Workflow run | diff-shades documentation

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.

Change the error report style to file:line:column

1 participant