mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-19 12:16:43 +00:00
The parser currently uses single quotes to wrap tokens. This is inconsistent with the rest of ruff/ty, which use backticks. For example, see the inconsistent diagnostics produced in this simple example: https://play.ty.dev/0a9d6eab-6599-4a1d-8e40-032091f7f50f Consistently wrapping tokens in backticks produces uniform diagnostics. Following the style decision of #723, in #2889 some quotes were already switched into backticks. This is also in line with Rust's guide on diagnostics (https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-structure): > When code or an identifier must appear in a message or label, it should be surrounded with backticks |
||
|---|---|---|
| .. | ||
| resources | ||
| src | ||
| tests | ||
| Cargo.toml | ||
| CONTRIBUTING.md | ||
| README.md | ||
Ruff Python Parser
Ruff's Python parser is a hand-written recursive descent parser which can parse Python source code into an Abstract Syntax Tree (AST). It also utilizes the Pratt parsing technique to parse expressions with different precedence.
Try out the parser in the playground.
Python version support
The parser supports the latest Python syntax, which is currently Python 3.12.
It does not throw syntax errors if it encounters a syntax feature that is not
supported by the target-version.
This will be fixed in a future release (see https://github.com/astral-sh/ruff/issues/6591).
Contributing
Refer to the contributing guidelines to get started and GitHub issues with the parser label for issues that need help.