Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add row and column numbers to formatted parse errors #9321

Merged
merged 1 commit into from
Dec 31, 2023

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Dec 30, 2023

Summary

We now render parse errors in the formatter identically to those in the linter, e.g.:

❯ cargo run -p ruff_cli -- format foo.py
error: Failed to parse foo.py:1:17: Unexpected token '='

Closes #8338.

Closes #9311.

Copy link
Contributor

github-actions bot commented Dec 30, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@charliermarsh charliermarsh force-pushed the charlie/display-parse-error branch from 380a61b to a043daa Compare December 30, 2023 21:18
@charliermarsh charliermarsh requested a review from zanieb December 30, 2023 21:18
@charliermarsh charliermarsh added bug Something isn't working cli Related to the command-line interface labels Dec 30, 2023
@charliermarsh charliermarsh force-pushed the charlie/display-parse-error branch from a043daa to 34d8bdd Compare December 30, 2023 21:20
@charliermarsh charliermarsh marked this pull request as ready for review December 30, 2023 21:20
@charliermarsh charliermarsh merged commit 48e04cc into main Dec 31, 2023
17 checks passed
@charliermarsh charliermarsh deleted the charlie/display-parse-error branch December 31, 2023 12:10
charliermarsh added a commit that referenced this pull request Dec 31, 2023
## Summary

This is a non-behavior-changing refactor to follow-up
#9321 by modifying
`DisplayParseError` to use owned data and make it useable as a
standalone error type (rather than using references and implementing
`Display`). I don't feel very strongly either way. I thought it was
awkward that the `FormatCommandError` had two branches in the display
path, and wanted to represent the `Parse` vs. other cases as a separate
enum, so here we are.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the command-line interface
Projects
None yet
2 participants