You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current user-facing messaging for syntax errors encountered during formatting are not friendly and are significantly worse than the linter's. The error should be normalized into a message instead of using the debug representation of ParseError
It'd also be nice to exit with a specific code if we only fail due to syntax errors rather than some sort of other failure :) that way we can report it nicely in the ecosystem checks instead of treating it as a failed run of Ruff.
## Summary
This helps a bit with (but does not close) the issues described in
#9311. E.g., now, we at least
see: `error: Failed to format main.py: source contains syntax errors:
invalid syntax. Got unexpected token '=' at byte offset 20`.
## 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.
The current user-facing messaging for syntax errors encountered during formatting are not friendly and are significantly worse than the linter's. The error should be normalized into a message instead of using the debug representation of
ParseError
e.g.
Line number not included (existing issue):
error: Failed to format commands/liberrors.py: source contains syntax errors: ParseError { error: UnrecognizedToken(Name { name: "THE_INVALID_FILE" }, None), offset: 208, source_path: "<filename>" } 157 files left unchanged
Cell number not included in notebook errors
error: Failed to format course/videos/domain_adaptation.ipynb: source contains syntax errors: ParseError { error: UnrecognizedToken(Rpar, None), offset: 70, source_path: "<filename>" }
The previous error is much nicer via the linter
error: Failed to parse course/videos/domain_adaptation.ipynb:cell 9:1:71: Unexpected token ')'
The text was updated successfully, but these errors were encountered: