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:
@@ -0,0 +1,3 @@
|
||||
# parse_options: {"target-version": "3.14"}
|
||||
t"{}"
|
||||
t"{ }"
|
||||
@@ -0,0 +1,2 @@
|
||||
# parse_options: {"target-version": "3.14"}
|
||||
t"{x!z}"
|
||||
@@ -0,0 +1,3 @@
|
||||
# parse_options: {"target-version": "3.14"}
|
||||
t"{x!123}"
|
||||
t"{x!'a'}"
|
||||
@@ -0,0 +1,5 @@
|
||||
# parse_options: {"target-version": "3.14"}
|
||||
# Starred expression inside t-string has a minimum precedence of bitwise or.
|
||||
t"{*}"
|
||||
t"{*x and y}"
|
||||
t"{*yield x}"
|
||||
@@ -0,0 +1,2 @@
|
||||
# parse_options: {"target-version": "3.14"}
|
||||
t"{lambda x: x}"
|
||||
@@ -0,0 +1,6 @@
|
||||
# parse_options: {"target-version": "3.14"}
|
||||
t"{"
|
||||
t"{foo!r"
|
||||
t"{foo="
|
||||
t"{"
|
||||
t"""{"""
|
||||
@@ -0,0 +1,3 @@
|
||||
# parse_options: {"target-version": "3.14"}
|
||||
t"hello {x:"
|
||||
t"hello {x:.3f"
|
||||
Reference in New Issue
Block a user