mirror of
https://github.com/astral-sh/ruff
synced 2026-01-07 06:34:07 -05: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:
@@ -15,7 +15,7 @@ from typing import Any
|
||||
import tomllib
|
||||
|
||||
# Types that require `crate::`. We can slowly remove these types as we move them to generate scripts.
|
||||
types_requiring_create_prefix = {
|
||||
types_requiring_crate_prefix = {
|
||||
"IpyEscapeKind",
|
||||
"ExprContext",
|
||||
"Identifier",
|
||||
@@ -23,6 +23,7 @@ types_requiring_create_prefix = {
|
||||
"BytesLiteralValue",
|
||||
"StringLiteralValue",
|
||||
"FStringValue",
|
||||
"TStringValue",
|
||||
"Arguments",
|
||||
"CmpOp",
|
||||
"Comprehension",
|
||||
@@ -762,7 +763,7 @@ def write_node(out: list[str], ast: Ast) -> None:
|
||||
ty = field.parsed_ty
|
||||
|
||||
rust_ty = f"{field.parsed_ty.name}"
|
||||
if ty.name in types_requiring_create_prefix:
|
||||
if ty.name in types_requiring_crate_prefix:
|
||||
rust_ty = f"crate::{rust_ty}"
|
||||
if ty.slice_:
|
||||
rust_ty = f"[{rust_ty}]"
|
||||
|
||||
Reference in New Issue
Block a user