mirror of
https://github.com/astral-sh/ruff
synced 2026-01-07 14:44:17 -05: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
809 B
809 B
Comprehensions with invalid syntax
# Missing `in` keyword.
# It's reasonably clear here what they *meant* to write,
# so we'll still infer the correct type:
# error: [invalid-syntax] "Expected `in`, found name"
# revealed: int
[reveal_type(a) for a range(3)]
# Missing iteration variable
# error: [invalid-syntax] "Expected an identifier, but found a keyword `in` that cannot be used here"
# error: [invalid-syntax] "Expected `in`, found name"
# error: [unresolved-reference]
# revealed: Unknown
[reveal_type(b) for in range(3)]
# Missing iterable
# error: [invalid-syntax] "Expected an expression"
# revealed: Unknown
[reveal_type(c) for c in]
# Missing `in` keyword and missing iterable
# error: [invalid-syntax] "Expected `in`, found `]`"
# revealed: Unknown
[reveal_type(d) for d]