mirror of
https://github.com/astral-sh/ruff
synced 2026-01-20 21:10:48 -05:00
Add row and column numbers to formatted parse errors (#9321)
## 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 https://github.com/astral-sh/ruff/issues/8338. Closes https://github.com/astral-sh/ruff/issues/9311.
This commit is contained in:
@@ -391,6 +391,15 @@ impl ParseErrorType {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LexicalError> for ParseError {
|
||||
fn from(error: LexicalError) -> Self {
|
||||
ParseError {
|
||||
error: ParseErrorType::Lexical(error.error),
|
||||
offset: error.location,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An expression that may be parenthesized.
|
||||
#[derive(Clone, Debug)]
|
||||
pub(super) struct ParenthesizedExpr {
|
||||
|
||||
Reference in New Issue
Block a user