Skip to content

Fix format --check spans for syntax errors - #27045

Merged
ntBre merged 1 commit into
brent/0.16.0from
brent/fix-format-check-line-number-3
Jul 21, 2026
Merged

ntBre merged 1 commit into
brent/0.16.0from
brent/fix-format-check-line-number-3

Conversation

@ntBre

@ntBre ntBre commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes #24528 by attaching more information to FormatCommandError::Parse instances. I made
a couple of attempts at Micha's suggestion (1) to convert to Diagnostics much earlier, but doing
this only for errors was pretty awkward while still producing a much larger diff. I think it would
be better to use diagnostics more deeply both for the error and non-error cases eventually, which
should also help with #8232, but I considered the limited fix here a better stopgap for the 0.16
release.

Test Plan

Updated snapshots for two existing tests, plus an additional notebook test

Summary
--

This PR fixes #24528 by attaching more information to `FormatCommandError::Parse` instances. I made
a couple of attempts at Micha's suggestion [1] to convert to `Diagnostic`s much earlier, but doing
this only for errors was pretty awkward while still producing a much larger diff. I think it would
be better to use diagnostics more deeply both for the error and non-error cases eventually, which
should also help with #8232, but I considered the limited fix here a better stopgap for the 0.16
release.

[1]: #24528 (comment)

Test Plan
--

Updated snapshots for two existing tests, plus an additional notebook test
@ntBre ntBre added this to the v0.16 milestone Jul 21, 2026
@ntBre ntBre added bug An issue describing something that isn't working, or a PR that fixes a bug diagnostics Diagnostic messages, annotations, fixes & rendering infra--not for PRs that just add new diagnostics labels Jul 21, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre
ntBre marked this pull request as ready for review July 21, 2026 16:07
@ntBre
ntBre requested a review from MichaReiser July 21, 2026 16:07
--> test.py:1:1
|
1 | 1
| ^

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.

This looks funny. Is this another poor parser diagnostic? I don't see any indentation?

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.

These are all synthetic diagnostics to test the rendering. This one is constructed on line 1294 above with a default range, and the input is just a "1" for all of them.

@ntBre
ntBre merged commit e16d075 into brent/0.16.0 Jul 21, 2026
47 checks passed
@ntBre
ntBre deleted the brent/fix-format-check-line-number-3 branch July 21, 2026 17:03
ntBre added a commit that referenced this pull request Jul 21, 2026
Summary
--

This PR fixes #24528 by attaching more information to
`FormatCommandError::Parse` instances. I made
a couple of attempts at Micha's suggestion ([1]) to convert to
`Diagnostic`s much earlier, but doing
this only for errors was pretty awkward while still producing a much
larger diff. I think it would
be better to use diagnostics more deeply both for the error and
non-error cases eventually, which
should also help with #8232, but I considered the limited fix here a
better stopgap for the 0.16
release.

[1]:
#24528 (comment)

Test Plan
--

Updated snapshots for two existing tests, plus an additional notebook
test
ntBre added a commit that referenced this pull request Jul 22, 2026
Summary
--

This PR fixes #24528 by attaching more information to
`FormatCommandError::Parse` instances. I made
a couple of attempts at Micha's suggestion ([1]) to convert to
`Diagnostic`s much earlier, but doing
this only for errors was pretty awkward while still producing a much
larger diff. I think it would
be better to use diagnostics more deeply both for the error and
non-error cases eventually, which
should also help with #8232, but I considered the limited fix here a
better stopgap for the 0.16
release.

[1]:
#24528 (comment)

Test Plan
--

Updated snapshots for two existing tests, plus an additional notebook
test
@ntBre ntBre mentioned this pull request Jul 23, 2026
2 tasks done
ntBre added a commit that referenced this pull request Jul 23, 2026
Summary
--

This PR fixes #24528 by attaching more information to
`FormatCommandError::Parse` instances. I made
a couple of attempts at Micha's suggestion ([1]) to convert to
`Diagnostic`s much earlier, but doing
this only for errors was pretty awkward while still producing a much
larger diff. I think it would
be better to use diagnostics more deeply both for the error and
non-error cases eventually, which
should also help with #8232, but I considered the limited fix here a
better stopgap for the 0.16
release.

[1]:
#24528 (comment)

Test Plan
--

Updated snapshots for two existing tests, plus an additional notebook
test
ntBre added a commit that referenced this pull request Jul 23, 2026
Summary
--

This PR fixes #24528 by attaching more information to
`FormatCommandError::Parse` instances. I made
a couple of attempts at Micha's suggestion ([1]) to convert to
`Diagnostic`s much earlier, but doing
this only for errors was pretty awkward while still producing a much
larger diff. I think it would
be better to use diagnostics more deeply both for the error and
non-error cases eventually, which
should also help with #8232, but I considered the limited fix here a
better stopgap for the 0.16
release.

[1]:
#24528 (comment)

Test Plan
--

Updated snapshots for two existing tests, plus an additional notebook
test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug diagnostics Diagnostic messages, annotations, fixes & rendering infra--not for PRs that just add new diagnostics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants