mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-16 01:25:22 +00:00
Implement template strings (#17851)
This PR implements template strings (t-strings) in the parser and formatter for Ruff. Minimal changes necessary to compile were made in other parts of the code (e.g. ty, the linter, etc.). These will be covered properly in follow-up PRs.
This commit is contained in:
parent
ad024f9a09
commit
9bbf4987e8
261 changed files with 18023 additions and 1802 deletions
|
@ -293,6 +293,7 @@ impl<'a> CanOmitOptionalParenthesesVisitor<'a> {
|
|||
// F-strings are allowed according to python's grammar but fail with a syntax error at runtime.
|
||||
// That's why we need to support them for formatting.
|
||||
Expr::FString(_) |
|
||||
Expr::TString(_)|
|
||||
Expr::NumberLiteral(_) | Expr::Attribute(_) | Expr::UnaryOp(_) => {
|
||||
// require no state update other than visit_pattern does.
|
||||
}
|
||||
|
@ -306,7 +307,7 @@ impl<'a> CanOmitOptionalParenthesesVisitor<'a> {
|
|||
_ => {
|
||||
debug_assert!(
|
||||
false,
|
||||
"Unsupported expression in pattern mach value: {:?}",
|
||||
"Unsupported expression in pattern match value: {:?}",
|
||||
value.value
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue