mirror of https://github.com/astral-sh/ruff
Disallow implicit concatenation of t-strings and other string types (#19485)
As of [this cpython PR](https://github.com/python/cpython/pull/135996), it is not allowed to concatenate t-strings with non-t-strings, implicitly or explicitly. Expressions such as `"foo" t"{bar}"` are now syntax errors. This PR updates some AST nodes and parsing to reflect this change. The structural change is that `TStringPart` is no longer needed, since, as in the case of `BytesStringLiteral`, the only possibilities are that we have a single `TString` or a vector of such (representing an implicit concatenation of t-strings). This removes a level of nesting from many AST expressions (which is what all the snapshot changes reflect), and simplifies some logic in the implementation of visitors, for example. The other change of note is in the parser. When we meet an implicit concatenation of string-like literals, we now count the number of t-string literals. If these do not exhaust the total number of implicitly concatenated pieces, then we emit a syntax error. To recover from this syntax error, we encode any t-string pieces as _invalid_ string literals (which means we flag them as invalid, record their range, and record the value as `""`). Note that if at least one of the pieces is an f-string we prefer to parse the entire string as an f-string; otherwise we parse it as a string. This logic is exactly the same as how we currently treat `BytesStringLiteral` parsing and error recovery - and carries with it the same pros and cons. Finally, note that I have not implemented any changes in the implementation of the formatter. As far as I can tell, none are needed. I did change a few of the fixtures so that we are always concatenating t-strings with t-strings.
This commit is contained in:
parent
df5eba7583
commit
008bbfdf5a
|
|
@ -25,5 +25,5 @@ def my_func():
|
||||||
|
|
||||||
# t-strings - all ok
|
# t-strings - all ok
|
||||||
t"0.0.0.0"
|
t"0.0.0.0"
|
||||||
"0.0.0.0" t"0.0.0.0{expr}0.0.0.0"
|
t"0.0.0.0" t"0.0.0.0{expr}0.0.0.0"
|
||||||
"0.0.0.0" f"0.0.0.0{expr}0.0.0.0" t"0.0.0.0{expr}0.0.0.0"
|
t"0.0.0.0" t"0.0.0.0{expr}0.0.0.0" t"0.0.0.0{expr}0.0.0.0"
|
||||||
|
|
|
||||||
|
|
@ -708,23 +708,10 @@ pub struct ComparableTString<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a ast::TStringValue> for ComparableTString<'a> {
|
impl<'a> From<&'a ast::TStringValue> for ComparableTString<'a> {
|
||||||
// The approach taken below necessarily deviates from the
|
// We model a [`ComparableTString`] on the actual
|
||||||
// corresponding implementation for [`ast::FStringValue`].
|
// [CPython implementation] of a `string.templatelib.Template` object.
|
||||||
// The reason is that a t-string value is composed of _three_
|
|
||||||
// non-comparable parts: literals, f-string expressions, and
|
|
||||||
// t-string interpolations. Since we have merged the AST nodes
|
|
||||||
// that capture f-string expressions and t-string interpolations
|
|
||||||
// into the shared [`ast::InterpolatedElement`], we must
|
|
||||||
// be careful to distinguish between them here.
|
|
||||||
//
|
//
|
||||||
// Consequently, we model a [`ComparableTString`] on the actual
|
// As in CPython, we must be careful to ensure that the length
|
||||||
// [CPython implementation] of a `string.templatelib.Template` object:
|
|
||||||
// it is composed of `strings` and `interpolations`. In CPython,
|
|
||||||
// the `strings` field is a tuple of honest strings (since f-strings
|
|
||||||
// are evaluated). Our `strings` field will house both f-string
|
|
||||||
// expressions and string literals.
|
|
||||||
//
|
|
||||||
// Finally, as in CPython, we must be careful to ensure that the length
|
|
||||||
// of `strings` is always one more than the length of `interpolations` -
|
// of `strings` is always one more than the length of `interpolations` -
|
||||||
// that way we can recover the original reading order by interleaving
|
// that way we can recover the original reading order by interleaving
|
||||||
// starting with `strings`. This is how we can tell the
|
// starting with `strings`. This is how we can tell the
|
||||||
|
|
@ -768,19 +755,6 @@ impl<'a> From<&'a ast::TStringValue> for ComparableTString<'a> {
|
||||||
.push(ComparableInterpolatedStringElement::Literal("".into()));
|
.push(ComparableInterpolatedStringElement::Literal("".into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_fstring_expression(&mut self, expression: &'a ast::InterpolatedElement) {
|
|
||||||
if let Some(ComparableInterpolatedStringElement::Literal(last_literal)) =
|
|
||||||
self.strings.last()
|
|
||||||
{
|
|
||||||
// Recall that we insert empty strings after
|
|
||||||
// each interpolation. If we encounter an f-string
|
|
||||||
// expression, we replace the empty string with it.
|
|
||||||
if last_literal.is_empty() {
|
|
||||||
self.strings.pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.strings.push(expression.into());
|
|
||||||
}
|
|
||||||
fn push_tstring_interpolation(&mut self, expression: &'a ast::InterpolatedElement) {
|
fn push_tstring_interpolation(&mut self, expression: &'a ast::InterpolatedElement) {
|
||||||
self.interpolations.push(expression.into());
|
self.interpolations.push(expression.into());
|
||||||
self.start_new_literal();
|
self.start_new_literal();
|
||||||
|
|
@ -789,34 +763,13 @@ impl<'a> From<&'a ast::TStringValue> for ComparableTString<'a> {
|
||||||
|
|
||||||
let mut collector = Collector::default();
|
let mut collector = Collector::default();
|
||||||
|
|
||||||
for part in value {
|
for element in value.elements() {
|
||||||
match part {
|
match element {
|
||||||
ast::TStringPart::Literal(string_literal) => {
|
ast::InterpolatedStringElement::Literal(literal) => {
|
||||||
collector.push_literal(&string_literal.value);
|
collector.push_literal(&literal.value);
|
||||||
}
|
}
|
||||||
ast::TStringPart::TString(fstring) => {
|
ast::InterpolatedStringElement::Interpolation(interpolation) => {
|
||||||
for element in &fstring.elements {
|
collector.push_tstring_interpolation(interpolation);
|
||||||
match element {
|
|
||||||
ast::InterpolatedStringElement::Literal(literal) => {
|
|
||||||
collector.push_literal(&literal.value);
|
|
||||||
}
|
|
||||||
ast::InterpolatedStringElement::Interpolation(interpolation) => {
|
|
||||||
collector.push_tstring_interpolation(interpolation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ast::TStringPart::FString(fstring) => {
|
|
||||||
for element in &fstring.elements {
|
|
||||||
match element {
|
|
||||||
ast::InterpolatedStringElement::Literal(literal) => {
|
|
||||||
collector.push_literal(&literal.value);
|
|
||||||
}
|
|
||||||
ast::InterpolatedStringElement::Interpolation(expression) => {
|
|
||||||
collector.push_fstring_expression(expression);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,7 @@ pub enum StringLikePartIter<'a> {
|
||||||
String(std::slice::Iter<'a, ast::StringLiteral>),
|
String(std::slice::Iter<'a, ast::StringLiteral>),
|
||||||
Bytes(std::slice::Iter<'a, ast::BytesLiteral>),
|
Bytes(std::slice::Iter<'a, ast::BytesLiteral>),
|
||||||
FString(std::slice::Iter<'a, ast::FStringPart>),
|
FString(std::slice::Iter<'a, ast::FStringPart>),
|
||||||
TString(std::slice::Iter<'a, ast::TStringPart>),
|
TString(std::slice::Iter<'a, ast::TString>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for StringLikePartIter<'a> {
|
impl<'a> Iterator for StringLikePartIter<'a> {
|
||||||
|
|
@ -339,16 +339,7 @@ impl<'a> Iterator for StringLikePartIter<'a> {
|
||||||
ast::FStringPart::FString(f_string) => StringLikePart::FString(f_string),
|
ast::FStringPart::FString(f_string) => StringLikePart::FString(f_string),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringLikePartIter::TString(inner) => {
|
StringLikePartIter::TString(inner) => StringLikePart::TString(inner.next()?),
|
||||||
let part = inner.next()?;
|
|
||||||
match part {
|
|
||||||
ast::TStringPart::Literal(string_literal) => {
|
|
||||||
StringLikePart::String(string_literal)
|
|
||||||
}
|
|
||||||
ast::TStringPart::TString(t_string) => StringLikePart::TString(t_string),
|
|
||||||
ast::TStringPart::FString(f_string) => StringLikePart::FString(f_string),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(part)
|
Some(part)
|
||||||
|
|
@ -378,16 +369,7 @@ impl DoubleEndedIterator for StringLikePartIter<'_> {
|
||||||
ast::FStringPart::FString(f_string) => StringLikePart::FString(f_string),
|
ast::FStringPart::FString(f_string) => StringLikePart::FString(f_string),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringLikePartIter::TString(inner) => {
|
StringLikePartIter::TString(inner) => StringLikePart::TString(inner.next_back()?),
|
||||||
let part = inner.next_back()?;
|
|
||||||
match part {
|
|
||||||
ast::TStringPart::Literal(string_literal) => {
|
|
||||||
StringLikePart::String(string_literal)
|
|
||||||
}
|
|
||||||
ast::TStringPart::TString(t_string) => StringLikePart::TString(t_string),
|
|
||||||
ast::TStringPart::FString(f_string) => StringLikePart::FString(f_string),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(part)
|
Some(part)
|
||||||
|
|
|
||||||
|
|
@ -1274,6 +1274,7 @@ impl Truthiness {
|
||||||
Self::Unknown
|
Self::Unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Expr::TString(_) => Self::Truthy,
|
||||||
Expr::List(ast::ExprList { elts, .. })
|
Expr::List(ast::ExprList { elts, .. })
|
||||||
| Expr::Set(ast::ExprSet { elts, .. })
|
| Expr::Set(ast::ExprSet { elts, .. })
|
||||||
| Expr::Tuple(ast::ExprTuple { elts, .. }) => {
|
| Expr::Tuple(ast::ExprTuple { elts, .. }) => {
|
||||||
|
|
@ -1362,6 +1363,7 @@ fn is_non_empty_f_string(expr: &ast::ExprFString) -> bool {
|
||||||
Expr::EllipsisLiteral(_) => true,
|
Expr::EllipsisLiteral(_) => true,
|
||||||
Expr::List(_) => true,
|
Expr::List(_) => true,
|
||||||
Expr::Tuple(_) => true,
|
Expr::Tuple(_) => true,
|
||||||
|
Expr::TString(_) => true,
|
||||||
|
|
||||||
// These expressions must resolve to the inner expression.
|
// These expressions must resolve to the inner expression.
|
||||||
Expr::If(ast::ExprIf { body, orelse, .. }) => inner(body) && inner(orelse),
|
Expr::If(ast::ExprIf { body, orelse, .. }) => inner(body) && inner(orelse),
|
||||||
|
|
@ -1386,7 +1388,6 @@ fn is_non_empty_f_string(expr: &ast::ExprFString) -> bool {
|
||||||
// These literals may or may not be empty.
|
// These literals may or may not be empty.
|
||||||
Expr::FString(f_string) => is_non_empty_f_string(f_string),
|
Expr::FString(f_string) => is_non_empty_f_string(f_string),
|
||||||
// These literals may or may not be empty.
|
// These literals may or may not be empty.
|
||||||
Expr::TString(f_string) => is_non_empty_t_string(f_string),
|
|
||||||
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => !value.is_empty(),
|
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => !value.is_empty(),
|
||||||
Expr::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => !value.is_empty(),
|
Expr::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => !value.is_empty(),
|
||||||
}
|
}
|
||||||
|
|
@ -1403,76 +1404,6 @@ fn is_non_empty_f_string(expr: &ast::ExprFString) -> bool {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the expression definitely resolves to a non-empty string, when used as an
|
|
||||||
/// f-string expression, or `false` if the expression may resolve to an empty string.
|
|
||||||
fn is_non_empty_t_string(expr: &ast::ExprTString) -> bool {
|
|
||||||
fn inner(expr: &Expr) -> bool {
|
|
||||||
match expr {
|
|
||||||
// When stringified, these expressions are always non-empty.
|
|
||||||
Expr::Lambda(_) => true,
|
|
||||||
Expr::Dict(_) => true,
|
|
||||||
Expr::Set(_) => true,
|
|
||||||
Expr::ListComp(_) => true,
|
|
||||||
Expr::SetComp(_) => true,
|
|
||||||
Expr::DictComp(_) => true,
|
|
||||||
Expr::Compare(_) => true,
|
|
||||||
Expr::NumberLiteral(_) => true,
|
|
||||||
Expr::BooleanLiteral(_) => true,
|
|
||||||
Expr::NoneLiteral(_) => true,
|
|
||||||
Expr::EllipsisLiteral(_) => true,
|
|
||||||
Expr::List(_) => true,
|
|
||||||
Expr::Tuple(_) => true,
|
|
||||||
|
|
||||||
// These expressions must resolve to the inner expression.
|
|
||||||
Expr::If(ast::ExprIf { body, orelse, .. }) => inner(body) && inner(orelse),
|
|
||||||
Expr::Named(ast::ExprNamed { value, .. }) => inner(value),
|
|
||||||
|
|
||||||
// These expressions are complex. We can't determine whether they're empty or not.
|
|
||||||
Expr::BoolOp(ast::ExprBoolOp { .. }) => false,
|
|
||||||
Expr::BinOp(ast::ExprBinOp { .. }) => false,
|
|
||||||
Expr::UnaryOp(ast::ExprUnaryOp { .. }) => false,
|
|
||||||
Expr::Generator(_) => false,
|
|
||||||
Expr::Await(_) => false,
|
|
||||||
Expr::Yield(_) => false,
|
|
||||||
Expr::YieldFrom(_) => false,
|
|
||||||
Expr::Call(_) => false,
|
|
||||||
Expr::Attribute(_) => false,
|
|
||||||
Expr::Subscript(_) => false,
|
|
||||||
Expr::Starred(_) => false,
|
|
||||||
Expr::Name(_) => false,
|
|
||||||
Expr::Slice(_) => false,
|
|
||||||
Expr::IpyEscapeCommand(_) => false,
|
|
||||||
|
|
||||||
// These literals may or may not be empty.
|
|
||||||
Expr::FString(f_string) => is_non_empty_f_string(f_string),
|
|
||||||
// These literals may or may not be empty.
|
|
||||||
Expr::TString(t_string) => is_non_empty_t_string(t_string),
|
|
||||||
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => !value.is_empty(),
|
|
||||||
Expr::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => !value.is_empty(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expr.value.iter().any(|part| match part {
|
|
||||||
ast::TStringPart::Literal(string_literal) => !string_literal.is_empty(),
|
|
||||||
ast::TStringPart::TString(t_string) => {
|
|
||||||
t_string.elements.iter().all(|element| match element {
|
|
||||||
ast::InterpolatedStringElement::Literal(string_literal) => {
|
|
||||||
!string_literal.is_empty()
|
|
||||||
}
|
|
||||||
ast::InterpolatedStringElement::Interpolation(t_string) => {
|
|
||||||
inner(&t_string.expression)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
ast::TStringPart::FString(f_string) => {
|
|
||||||
f_string.elements.iter().all(|element| match element {
|
|
||||||
InterpolatedStringElement::Literal(string_literal) => !string_literal.is_empty(),
|
|
||||||
InterpolatedStringElement::Interpolation(f_string) => inner(&f_string.expression),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `true` if the expression definitely resolves to the empty string, when used as an f-string
|
/// Returns `true` if the expression definitely resolves to the empty string, when used as an f-string
|
||||||
/// expression.
|
/// expression.
|
||||||
fn is_empty_f_string(expr: &ast::ExprFString) -> bool {
|
fn is_empty_f_string(expr: &ast::ExprFString) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -171,18 +171,8 @@ impl ast::ExprTString {
|
||||||
node_index: _,
|
node_index: _,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
for t_string_part in value {
|
for t_string in value {
|
||||||
match t_string_part {
|
visitor.visit_t_string(t_string);
|
||||||
ast::TStringPart::Literal(string_literal) => {
|
|
||||||
visitor.visit_string_literal(string_literal);
|
|
||||||
}
|
|
||||||
ast::TStringPart::FString(f_string) => {
|
|
||||||
visitor.visit_f_string(f_string);
|
|
||||||
}
|
|
||||||
ast::TStringPart::TString(t_string) => {
|
|
||||||
visitor.visit_t_string(t_string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -597,8 +597,8 @@ impl ExprTString {
|
||||||
/// otherwise.
|
/// otherwise.
|
||||||
pub const fn as_single_part_tstring(&self) -> Option<&TString> {
|
pub const fn as_single_part_tstring(&self) -> Option<&TString> {
|
||||||
match &self.value.inner {
|
match &self.value.inner {
|
||||||
TStringValueInner::Single(TStringPart::TString(tstring)) => Some(tstring),
|
TStringValueInner::Single(tstring) => Some(tstring),
|
||||||
_ => None,
|
TStringValueInner::Concatenated(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -614,7 +614,7 @@ impl TStringValue {
|
||||||
/// Creates a new t-string literal with a single [`TString`] part.
|
/// Creates a new t-string literal with a single [`TString`] part.
|
||||||
pub fn single(value: TString) -> Self {
|
pub fn single(value: TString) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: TStringValueInner::Single(TStringPart::TString(value)),
|
inner: TStringValueInner::Single(value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -625,7 +625,7 @@ impl TStringValue {
|
||||||
///
|
///
|
||||||
/// Panics if `values` has less than 2 elements.
|
/// Panics if `values` has less than 2 elements.
|
||||||
/// Use [`TStringValue::single`] instead.
|
/// Use [`TStringValue::single`] instead.
|
||||||
pub fn concatenated(values: Vec<TStringPart>) -> Self {
|
pub fn concatenated(values: Vec<TString>) -> Self {
|
||||||
assert!(
|
assert!(
|
||||||
values.len() > 1,
|
values.len() > 1,
|
||||||
"Use `TStringValue::single` to create single-part t-strings"
|
"Use `TStringValue::single` to create single-part t-strings"
|
||||||
|
|
@ -640,78 +640,52 @@ impl TStringValue {
|
||||||
matches!(self.inner, TStringValueInner::Concatenated(_))
|
matches!(self.inner, TStringValueInner::Concatenated(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a slice of all the [`TStringPart`]s contained in this value.
|
/// Returns a slice of all the [`TString`]s contained in this value.
|
||||||
pub fn as_slice(&self) -> &[TStringPart] {
|
pub fn as_slice(&self) -> &[TString] {
|
||||||
match &self.inner {
|
match &self.inner {
|
||||||
TStringValueInner::Single(part) => std::slice::from_ref(part),
|
TStringValueInner::Single(part) => std::slice::from_ref(part),
|
||||||
TStringValueInner::Concatenated(parts) => parts,
|
TStringValueInner::Concatenated(parts) => parts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a mutable slice of all the [`TStringPart`]s contained in this value.
|
/// Returns a mutable slice of all the [`TString`]s contained in this value.
|
||||||
fn as_mut_slice(&mut self) -> &mut [TStringPart] {
|
fn as_mut_slice(&mut self) -> &mut [TString] {
|
||||||
match &mut self.inner {
|
match &mut self.inner {
|
||||||
TStringValueInner::Single(part) => std::slice::from_mut(part),
|
TStringValueInner::Single(part) => std::slice::from_mut(part),
|
||||||
TStringValueInner::Concatenated(parts) => parts,
|
TStringValueInner::Concatenated(parts) => parts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over all the [`TStringPart`]s contained in this value.
|
/// Returns an iterator over all the [`TString`]s contained in this value.
|
||||||
pub fn iter(&self) -> Iter<TStringPart> {
|
pub fn iter(&self) -> Iter<TString> {
|
||||||
self.as_slice().iter()
|
self.as_slice().iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over all the [`TStringPart`]s contained in this value
|
/// Returns an iterator over all the [`TString`]s contained in this value
|
||||||
/// that allows modification.
|
/// that allows modification.
|
||||||
pub fn iter_mut(&mut self) -> IterMut<TStringPart> {
|
pub fn iter_mut(&mut self) -> IterMut<TString> {
|
||||||
self.as_mut_slice().iter_mut()
|
self.as_mut_slice().iter_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over the [`StringLiteral`] parts contained in this value.
|
|
||||||
///
|
|
||||||
/// Note that this doesn't recurse into the t-string parts. For example,
|
|
||||||
///
|
|
||||||
/// ```python
|
|
||||||
/// "foo" t"bar {x}" "baz" t"qux"
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Here, the string literal parts returned would be `"foo"` and `"baz"`.
|
|
||||||
pub fn literals(&self) -> impl Iterator<Item = &StringLiteral> {
|
|
||||||
self.iter().filter_map(|part| part.as_literal())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns an iterator over the [`TString`] parts contained in this value.
|
|
||||||
///
|
|
||||||
/// Note that this doesn't recurse into the t-string parts. For example,
|
|
||||||
///
|
|
||||||
/// ```python
|
|
||||||
/// "foo" t"bar {x}" "baz" t"qux"
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Here, the t-string parts returned would be `f"bar {x}"` and `f"qux"`.
|
|
||||||
pub fn t_strings(&self) -> impl Iterator<Item = &TString> {
|
|
||||||
self.iter().filter_map(|part| part.as_t_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns an iterator over all the [`InterpolatedStringElement`] contained in this value.
|
/// Returns an iterator over all the [`InterpolatedStringElement`] contained in this value.
|
||||||
///
|
///
|
||||||
/// An t-string element is what makes up an [`TString`] i.e., it is either a
|
/// An interpolated string element is what makes up an [`TString`] i.e., it is either a
|
||||||
/// string literal or an interpolation. In the following example,
|
/// string literal or an interpolation. In the following example,
|
||||||
///
|
///
|
||||||
/// ```python
|
/// ```python
|
||||||
/// "foo" t"bar {x}" "baz" t"qux"
|
/// t"foo" t"bar {x}" t"baz" t"qux"
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// The t-string elements returned would be string literal (`"bar "`),
|
/// The interpolated string elements returned would be string literal (`"bar "`),
|
||||||
/// interpolation (`x`) and string literal (`"qux"`).
|
/// interpolation (`x`) and string literal (`"qux"`).
|
||||||
pub fn elements(&self) -> impl Iterator<Item = &InterpolatedStringElement> {
|
pub fn elements(&self) -> impl Iterator<Item = &InterpolatedStringElement> {
|
||||||
self.t_strings().flat_map(|fstring| fstring.elements.iter())
|
self.iter().flat_map(|tstring| tstring.elements.iter())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoIterator for &'a TStringValue {
|
impl<'a> IntoIterator for &'a TStringValue {
|
||||||
type Item = &'a TStringPart;
|
type Item = &'a TString;
|
||||||
type IntoIter = Iter<'a, TStringPart>;
|
type IntoIter = Iter<'a, TString>;
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
self.iter()
|
self.iter()
|
||||||
|
|
@ -719,8 +693,8 @@ impl<'a> IntoIterator for &'a TStringValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoIterator for &'a mut TStringValue {
|
impl<'a> IntoIterator for &'a mut TStringValue {
|
||||||
type Item = &'a mut TStringPart;
|
type Item = &'a mut TString;
|
||||||
type IntoIter = IterMut<'a, TStringPart>;
|
type IntoIter = IterMut<'a, TString>;
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
self.iter_mut()
|
self.iter_mut()
|
||||||
}
|
}
|
||||||
|
|
@ -731,43 +705,10 @@ impl<'a> IntoIterator for &'a mut TStringValue {
|
||||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||||
enum TStringValueInner {
|
enum TStringValueInner {
|
||||||
/// A single t-string i.e., `t"foo"`.
|
/// A single t-string i.e., `t"foo"`.
|
||||||
///
|
Single(TString),
|
||||||
/// This is always going to be `TStringPart::TString` variant which is
|
|
||||||
/// maintained by the `TStringValue::single` constructor.
|
|
||||||
Single(TStringPart),
|
|
||||||
|
|
||||||
/// An implicitly concatenated t-string i.e., `"foo" t"bar {x}"`.
|
/// An implicitly concatenated t-string i.e., `t"foo" t"bar {x}"`.
|
||||||
Concatenated(Vec<TStringPart>),
|
Concatenated(Vec<TString>),
|
||||||
}
|
|
||||||
|
|
||||||
/// An t-string part which is either a string literal, an f-string,
|
|
||||||
/// or a t-string.
|
|
||||||
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
|
|
||||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
|
||||||
pub enum TStringPart {
|
|
||||||
Literal(StringLiteral),
|
|
||||||
FString(FString),
|
|
||||||
TString(TString),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TStringPart {
|
|
||||||
pub fn quote_style(&self) -> Quote {
|
|
||||||
match self {
|
|
||||||
Self::Literal(string_literal) => string_literal.flags.quote_style(),
|
|
||||||
Self::FString(f_string) => f_string.flags.quote_style(),
|
|
||||||
Self::TString(t_string) => t_string.flags.quote_style(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Ranged for TStringPart {
|
|
||||||
fn range(&self) -> TextRange {
|
|
||||||
match self {
|
|
||||||
TStringPart::Literal(string_literal) => string_literal.range(),
|
|
||||||
TStringPart::FString(f_string) => f_string.range(),
|
|
||||||
TStringPart::TString(t_string) => t_string.range(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait StringFlags: Copy {
|
pub trait StringFlags: Copy {
|
||||||
|
|
@ -1237,6 +1178,12 @@ pub struct TString {
|
||||||
pub flags: TStringFlags,
|
pub flags: TStringFlags,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TString {
|
||||||
|
pub fn quote_style(&self) -> Quote {
|
||||||
|
self.flags.quote_style()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<TString> for Expr {
|
impl From<TString> for Expr {
|
||||||
fn from(payload: TString) -> Self {
|
fn from(payload: TString) -> Self {
|
||||||
ExprTString {
|
ExprTString {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ use crate::{
|
||||||
self as ast, Alias, AnyParameterRef, Arguments, BoolOp, BytesLiteral, CmpOp, Comprehension,
|
self as ast, Alias, AnyParameterRef, Arguments, BoolOp, BytesLiteral, CmpOp, Comprehension,
|
||||||
Decorator, ElifElseClause, ExceptHandler, Expr, ExprContext, FString, FStringPart,
|
Decorator, ElifElseClause, ExceptHandler, Expr, ExprContext, FString, FStringPart,
|
||||||
InterpolatedStringElement, Keyword, MatchCase, Operator, Parameter, Parameters, Pattern,
|
InterpolatedStringElement, Keyword, MatchCase, Operator, Parameter, Parameters, Pattern,
|
||||||
PatternArguments, PatternKeyword, Stmt, StringLiteral, TString, TStringPart, TypeParam,
|
PatternArguments, PatternKeyword, Stmt, StringLiteral, TString, TypeParam, TypeParamParamSpec,
|
||||||
TypeParamParamSpec, TypeParamTypeVar, TypeParamTypeVarTuple, TypeParams, UnaryOp, WithItem,
|
TypeParamTypeVar, TypeParamTypeVarTuple, TypeParams, UnaryOp, WithItem,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A trait for AST visitors. Visits all nodes in the AST recursively in evaluation-order.
|
/// A trait for AST visitors. Visits all nodes in the AST recursively in evaluation-order.
|
||||||
|
|
@ -547,14 +547,8 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::TString(ast::ExprTString { value, .. }) => {
|
Expr::TString(ast::ExprTString { value, .. }) => {
|
||||||
for part in value {
|
for t_string in value {
|
||||||
match part {
|
visitor.visit_t_string(t_string);
|
||||||
TStringPart::Literal(string_literal) => {
|
|
||||||
visitor.visit_string_literal(string_literal);
|
|
||||||
}
|
|
||||||
TStringPart::FString(f_string) => visitor.visit_f_string(f_string),
|
|
||||||
TStringPart::TString(t_string) => visitor.visit_t_string(t_string),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
|
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
|
||||||
|
|
|
||||||
|
|
@ -533,18 +533,8 @@ pub fn walk_expr<V: Transformer + ?Sized>(visitor: &V, expr: &mut Expr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::TString(ast::ExprTString { value, .. }) => {
|
Expr::TString(ast::ExprTString { value, .. }) => {
|
||||||
for t_string_part in value.iter_mut() {
|
for t_string in value.iter_mut() {
|
||||||
match t_string_part {
|
visitor.visit_t_string(t_string);
|
||||||
ast::TStringPart::Literal(string_literal) => {
|
|
||||||
visitor.visit_string_literal(string_literal);
|
|
||||||
}
|
|
||||||
ast::TStringPart::FString(f_string) => {
|
|
||||||
visitor.visit_f_string(f_string);
|
|
||||||
}
|
|
||||||
ast::TStringPart::TString(t_string) => {
|
|
||||||
visitor.visit_t_string(t_string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
|
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
|
||||||
|
|
|
||||||
|
|
@ -51,28 +51,12 @@ fn concatenated_fstrings_compare_equal() -> Result<(), ParseError> {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn concatenated_tstrings_compare_equal() -> Result<(), ParseError> {
|
fn concatenated_tstrings_compare_equal() -> Result<(), ParseError> {
|
||||||
let split_contents = r#"t"{foo!r} this" r"\n raw" t" and {bar!s} that""#;
|
let split_contents = r#"t"{foo!r} this" rt"\n raw" t" and {bar!s} that""#;
|
||||||
let value_contents = r#"t"{foo!r} this\\n raw and {bar!s} that""#;
|
let value_contents = r#"t"{foo!r} this\\n raw and {bar!s} that""#;
|
||||||
|
|
||||||
assert_comparable(split_contents, value_contents)
|
assert_comparable(split_contents, value_contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn concatenated_f_and_t_strings_interwoven_compare_equal() -> Result<(), ParseError> {
|
|
||||||
let split_contents = r#"f"{foo} this " t"{bar}" "baz""#;
|
|
||||||
let value_contents = r#"f"{foo}" t" this {bar}" "baz""#;
|
|
||||||
|
|
||||||
assert_comparable(split_contents, value_contents)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn concatenated_f_and_t_strings_compare_unequal_when_swapped() -> Result<(), ParseError> {
|
|
||||||
let f_then_t_contents = r#"f"{foo!r} this" r"\n raw" t" and {bar!s} that""#;
|
|
||||||
let t_then_f_contents = r#"t"{foo!r} this" r"\n raw" f" and {bar!s} that""#;
|
|
||||||
|
|
||||||
assert_noncomparable(f_then_t_contents, t_then_f_contents)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn t_strings_literal_order_matters_compare_unequal() -> Result<(), ParseError> {
|
fn t_strings_literal_order_matters_compare_unequal() -> Result<(), ParseError> {
|
||||||
let interp_then_literal_contents = r#"t"{foo}bar""#;
|
let interp_then_literal_contents = r#"t"{foo}bar""#;
|
||||||
|
|
@ -80,11 +64,3 @@ fn t_strings_literal_order_matters_compare_unequal() -> Result<(), ParseError> {
|
||||||
|
|
||||||
assert_noncomparable(interp_then_literal_contents, literal_then_interp_contents)
|
assert_noncomparable(interp_then_literal_contents, literal_then_interp_contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn t_strings_empty_concat_equal() -> Result<(), ParseError> {
|
|
||||||
let empty_literal = r#""" t"hey{foo}""#;
|
|
||||||
let empty_f_string = r#"f""t"hey{foo}""#;
|
|
||||||
|
|
||||||
assert_comparable(empty_literal, empty_f_string)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ expression: trace
|
||||||
- ModModule
|
- ModModule
|
||||||
- StmtExpr
|
- StmtExpr
|
||||||
- ExprTString
|
- ExprTString
|
||||||
- StringLiteral
|
- TString
|
||||||
|
- InterpolatedStringLiteralElement
|
||||||
- TString
|
- TString
|
||||||
- InterpolatedStringLiteralElement
|
- InterpolatedStringLiteralElement
|
||||||
- InterpolatedElement
|
- InterpolatedElement
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ expression: trace
|
||||||
---
|
---
|
||||||
- StmtExpr
|
- StmtExpr
|
||||||
- ExprTString
|
- ExprTString
|
||||||
- StringLiteral
|
- TString
|
||||||
|
- InterpolatedStringLiteralElement
|
||||||
- TString
|
- TString
|
||||||
- InterpolatedStringLiteralElement
|
- InterpolatedStringLiteralElement
|
||||||
- InterpolatedElement
|
- InterpolatedElement
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ fn f_strings() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn t_strings() {
|
fn t_strings() {
|
||||||
let source = r"'pre' t'foo {bar:.{x}f} baz'";
|
let source = r"t'pre' t'foo {bar:.{x}f} baz'";
|
||||||
|
|
||||||
let trace = trace_source_order_visitation(source);
|
let trace = trace_source_order_visitation(source);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ fn f_strings() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn t_strings() {
|
fn t_strings() {
|
||||||
let source = r"'pre' t'foo {bar:.{x}f} baz'";
|
let source = r"t'pre' t'foo {bar:.{x}f} baz'";
|
||||||
|
|
||||||
let trace = trace_visitation(source);
|
let trace = trace_visitation(source);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1538,19 +1538,9 @@ impl<'a> Generator<'a> {
|
||||||
|
|
||||||
fn unparse_t_string_value(&mut self, value: &ast::TStringValue) {
|
fn unparse_t_string_value(&mut self, value: &ast::TStringValue) {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for t_string_part in value {
|
for t_string in value {
|
||||||
self.p_delim(&mut first, " ");
|
self.p_delim(&mut first, " ");
|
||||||
match t_string_part {
|
self.unparse_interpolated_string(&t_string.elements, t_string.flags.into());
|
||||||
ast::TStringPart::Literal(string_literal) => {
|
|
||||||
self.unparse_string_literal(string_literal);
|
|
||||||
}
|
|
||||||
ast::TStringPart::FString(f_string) => {
|
|
||||||
self.unparse_interpolated_string(&f_string.elements, f_string.flags.into());
|
|
||||||
}
|
|
||||||
ast::TStringPart::TString(t_string) => {
|
|
||||||
self.unparse_interpolated_string(&t_string.elements, t_string.flags.into());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,16 +104,13 @@ f"{10 + len('bar')=}" f'{10 + len("bar")=}'
|
||||||
# T-strings
|
# T-strings
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Escape `{` and `}` when merging a t-string with a string
|
|
||||||
"a {not_a_variable}" t"b {10}" "c"
|
|
||||||
|
|
||||||
# Join, and break expressions
|
# Join, and break expressions
|
||||||
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{
|
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{
|
||||||
expression
|
expression
|
||||||
}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" t"cccccccccccccccccccc {20999}" "more"
|
}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" t"cccccccccccccccccccc {20999}" t"more"
|
||||||
|
|
||||||
# Join, but don't break the expressions
|
# Join, but don't break the expressions
|
||||||
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{expression}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" t"cccccccccccccccccccc {20999}" "more"
|
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{expression}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" t"cccccccccccccccccccc {20999}" t"more"
|
||||||
|
|
||||||
t"test{
|
t"test{
|
||||||
expression
|
expression
|
||||||
|
|
@ -171,22 +168,11 @@ t"test" tR"test"
|
||||||
|
|
||||||
"single" f""""single"""
|
"single" f""""single"""
|
||||||
|
|
||||||
"single" t""""single"""
|
t"single" t""""single"""
|
||||||
|
|
||||||
b"single" b"""triple"""
|
b"single" b"""triple"""
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
# Don't join t-strings and f-strings
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
t"{interp}" f"{expr}"
|
|
||||||
|
|
||||||
f"{expr}" t"{interp}"
|
|
||||||
|
|
||||||
f"{expr}" "string" t"{interp}"
|
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Join strings in with statements
|
# Join strings in with statements
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ a[
|
||||||
b
|
b
|
||||||
] = (
|
] = (
|
||||||
t"ccccc{
|
t"ccccc{
|
||||||
expression}ccccccccccc" "cccccccccccccccccccccccc" # comment
|
expression}ccccccccccc" t"cccccccccccccccccccccccc" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Same but starting with a joined string. They should both result in the same formatting.
|
# Same but starting with a joined string. They should both result in the same formatting.
|
||||||
|
|
@ -361,7 +361,7 @@ a[
|
||||||
aaaaaaa,
|
aaaaaaa,
|
||||||
b
|
b
|
||||||
] = t"ccccc{
|
] = t"ccccc{
|
||||||
expression}ccccccccccc" "ccccccccccccccccccccccccccccccccccccccccccc" # comment
|
expression}ccccccccccc" t"ccccccccccccccccccccccccccccccccccccccccccc" # comment
|
||||||
|
|
||||||
|
|
||||||
# Split an overlong target, but join the string if it fits
|
# Split an overlong target, but join the string if it fits
|
||||||
|
|
@ -370,7 +370,7 @@ a[
|
||||||
b
|
b
|
||||||
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
||||||
t"ccccc{
|
t"ccccc{
|
||||||
expression}ccccccccccc" "cccccccccccccccccccccccccccccc" # comment
|
expression}ccccccccccc" t"cccccccccccccccccccccccccccccc" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Split both if necessary and keep multiline
|
# Split both if necessary and keep multiline
|
||||||
|
|
@ -379,66 +379,66 @@ a[
|
||||||
b
|
b
|
||||||
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
||||||
t"ccccc{
|
t"ccccc{
|
||||||
expression}cccccccccccccccccccccccccccccccc" "ccccccccccccccccccccccccccccccc" # comment
|
expression}cccccccccccccccccccccccccccccccc" t"ccccccccccccccccccccccccccccccc" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Don't inline t-strings that contain expressions that are guaranteed to split, e.b. because of a magic trailing comma
|
# Don't inline t-strings that contain expressions that are guaranteed to split, e.b. because of a magic trailing comma
|
||||||
aaaaaaaaaaaaaaaaaa = t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
aaaaaaaaaaaaaaaaaa = t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
[a,]
|
[a,]
|
||||||
}" "moreeeeeeeeeeeeeeeeeeee" "test" # comment
|
}" t"moreeeeeeeeeeeeeeeeeeee" t"test" # comment
|
||||||
|
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
[a,]
|
[a,]
|
||||||
}" "moreeeeeeeeeeeeeeeeeeee" "test" # comment
|
}" t"moreeeeeeeeeeeeeeeeeeee" t"test" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
aaaaa[aaaaaaaaaaa] = t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
[a,]
|
[a,]
|
||||||
}" "moreeeeeeeeeeeeeeeeeeee" "test" # comment
|
}" t"moreeeeeeeeeeeeeeeeeeee" t"test" # comment
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
aaaaa[aaaaaaaaaaa] = (t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
[a,]
|
[a,]
|
||||||
}" "moreeeeeeeeeeeeeeeeeeee" "test" # comment
|
}" t"moreeeeeeeeeeeeeeeeeeee" t"test" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Don't inline t-strings that contain commented expressions
|
# Don't inline t-strings that contain commented expressions
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{[
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{[
|
||||||
a # comment
|
a # comment
|
||||||
]}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
]}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{[
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{[
|
||||||
a # comment
|
a # comment
|
||||||
]}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
]}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Don't inline t-strings with multiline debug expressions:
|
# Don't inline t-strings with multiline debug expressions:
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
a=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
a=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a +
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a +
|
||||||
b=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
b=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
||||||
=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
a=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
a=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
||||||
=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -499,7 +499,7 @@ a = (
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.error(
|
logger.error(
|
||||||
f"Failed to run task {task} for job"
|
f"Failed to run task {task} for job"
|
||||||
f"with id {str(job.id)}" # type: ignore[union-attr]
|
f"with id {str(job.id)}" # type: ignore[union-attr]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,21 @@ rt"Not-so-tricky \"quote"
|
||||||
|
|
||||||
# Regression test for tstrings dropping comments
|
# Regression test for tstrings dropping comments
|
||||||
result_f = (
|
result_f = (
|
||||||
'Traceback (most recent call last):\n'
|
t'Traceback (most recent call last):\n'
|
||||||
t' File "{__file__}", line {lineno_f+5}, in _check_recursive_traceback_display\n'
|
t' File "{__file__}", line {lineno_f+5}, in _check_recursive_traceback_display\n'
|
||||||
' f()\n'
|
t' f()\n'
|
||||||
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
||||||
' f()\n'
|
t' f()\n'
|
||||||
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
||||||
' f()\n'
|
t' f()\n'
|
||||||
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
||||||
' f()\n'
|
t' f()\n'
|
||||||
# XXX: The following line changes depending on whether the tests
|
# XXX: The following line changes depending on whether the tests
|
||||||
# are run through the interactive interpreter or with -m
|
# are run through the interactive interpreter or with -m
|
||||||
# It also varies depending on the platform (stack size)
|
# It also varies depending on the platform (stack size)
|
||||||
# Fortunately, we don't care about exactness here, so we use regex
|
# Fortunately, we don't care about exactness here, so we use regex
|
||||||
r' \[Previous line repeated (\d+) more times\]' '\n'
|
rt' \[Previous line repeated (\d+) more times\]' t'\n'
|
||||||
'RecursionError: maximum recursion depth exceeded\n'
|
t'RecursionError: maximum recursion depth exceeded\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ result_f = (
|
||||||
(
|
(
|
||||||
t'{1}'
|
t'{1}'
|
||||||
# comment 1
|
# comment 1
|
||||||
''
|
t''
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
@ -655,7 +655,7 @@ hello {
|
||||||
|
|
||||||
# Implicit concatenated t-string containing quotes
|
# Implicit concatenated t-string containing quotes
|
||||||
_ = (
|
_ = (
|
||||||
'This string should change its quotes to double quotes'
|
t'This string should change its quotes to double quotes'
|
||||||
t'This string uses double quotes in an expression {"it's a quote"}'
|
t'This string uses double quotes in an expression {"it's a quote"}'
|
||||||
t'This t-string does not use any quotes.'
|
t'This t-string does not use any quotes.'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -110,16 +110,13 @@ f"{10 + len('bar')=}" f'{10 + len("bar")=}'
|
||||||
# T-strings
|
# T-strings
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Escape `{` and `}` when merging a t-string with a string
|
|
||||||
"a {not_a_variable}" t"b {10}" "c"
|
|
||||||
|
|
||||||
# Join, and break expressions
|
# Join, and break expressions
|
||||||
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{
|
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{
|
||||||
expression
|
expression
|
||||||
}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" t"cccccccccccccccccccc {20999}" "more"
|
}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" t"cccccccccccccccccccc {20999}" t"more"
|
||||||
|
|
||||||
# Join, but don't break the expressions
|
# Join, but don't break the expressions
|
||||||
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{expression}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" t"cccccccccccccccccccc {20999}" "more"
|
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{expression}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" t"cccccccccccccccccccc {20999}" t"more"
|
||||||
|
|
||||||
t"test{
|
t"test{
|
||||||
expression
|
expression
|
||||||
|
|
@ -177,22 +174,11 @@ t"test" tR"test"
|
||||||
|
|
||||||
"single" f""""single"""
|
"single" f""""single"""
|
||||||
|
|
||||||
"single" t""""single"""
|
t"single" t""""single"""
|
||||||
|
|
||||||
b"single" b"""triple"""
|
b"single" b"""triple"""
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
# Don't join t-strings and f-strings
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
t"{interp}" f"{expr}"
|
|
||||||
|
|
||||||
f"{expr}" t"{interp}"
|
|
||||||
|
|
||||||
f"{expr}" "string" t"{interp}"
|
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Join strings in with statements
|
# Join strings in with statements
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
@ -521,9 +507,6 @@ f"{10 + len('bar')=}" f'{10 + len("bar")=}'
|
||||||
# T-strings
|
# T-strings
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Escape `{` and `}` when merging a t-string with a string
|
|
||||||
t"a {{not_a_variable}}b {10}c"
|
|
||||||
|
|
||||||
# Join, and break expressions
|
# Join, and break expressions
|
||||||
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{
|
t"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{
|
||||||
expression
|
expression
|
||||||
|
|
@ -583,22 +566,11 @@ t"test" Rt"test"
|
||||||
|
|
||||||
"single" f""""single"""
|
"single" f""""single"""
|
||||||
|
|
||||||
"single" t""""single"""
|
t"single" t""""single"""
|
||||||
|
|
||||||
b"single" b"""triple"""
|
b"single" b"""triple"""
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
# Don't join t-strings and f-strings
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
t"{interp}" f"{expr}"
|
|
||||||
|
|
||||||
f"{expr}" t"{interp}"
|
|
||||||
|
|
||||||
f"{expr}" "string" t"{interp}"
|
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Join strings in with statements
|
# Join strings in with statements
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
@ -905,7 +877,7 @@ f"aaaaaaaaaaaaaaaa \
|
||||||
```diff
|
```diff
|
||||||
--- Stable
|
--- Stable
|
||||||
+++ Preview
|
+++ Preview
|
||||||
@@ -302,9 +302,12 @@
|
@@ -288,9 +288,12 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Use can_omit_optional_parentheses layout to avoid an instability where the formatter
|
# Use can_omit_optional_parentheses layout to avoid an instability where the formatter
|
||||||
# picks the can_omit_optional_parentheses layout when the strings are joined.
|
# picks the can_omit_optional_parentheses layout when the strings are joined.
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,7 @@ a[
|
||||||
b
|
b
|
||||||
] = (
|
] = (
|
||||||
t"ccccc{
|
t"ccccc{
|
||||||
expression}ccccccccccc" "cccccccccccccccccccccccc" # comment
|
expression}ccccccccccc" t"cccccccccccccccccccccccc" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Same but starting with a joined string. They should both result in the same formatting.
|
# Same but starting with a joined string. They should both result in the same formatting.
|
||||||
|
|
@ -367,7 +367,7 @@ a[
|
||||||
aaaaaaa,
|
aaaaaaa,
|
||||||
b
|
b
|
||||||
] = t"ccccc{
|
] = t"ccccc{
|
||||||
expression}ccccccccccc" "ccccccccccccccccccccccccccccccccccccccccccc" # comment
|
expression}ccccccccccc" t"ccccccccccccccccccccccccccccccccccccccccccc" # comment
|
||||||
|
|
||||||
|
|
||||||
# Split an overlong target, but join the string if it fits
|
# Split an overlong target, but join the string if it fits
|
||||||
|
|
@ -376,7 +376,7 @@ a[
|
||||||
b
|
b
|
||||||
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
||||||
t"ccccc{
|
t"ccccc{
|
||||||
expression}ccccccccccc" "cccccccccccccccccccccccccccccc" # comment
|
expression}ccccccccccc" t"cccccccccccccccccccccccccccccc" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Split both if necessary and keep multiline
|
# Split both if necessary and keep multiline
|
||||||
|
|
@ -385,66 +385,66 @@ a[
|
||||||
b
|
b
|
||||||
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
||||||
t"ccccc{
|
t"ccccc{
|
||||||
expression}cccccccccccccccccccccccccccccccc" "ccccccccccccccccccccccccccccccc" # comment
|
expression}cccccccccccccccccccccccccccccccc" t"ccccccccccccccccccccccccccccccc" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Don't inline t-strings that contain expressions that are guaranteed to split, e.b. because of a magic trailing comma
|
# Don't inline t-strings that contain expressions that are guaranteed to split, e.b. because of a magic trailing comma
|
||||||
aaaaaaaaaaaaaaaaaa = t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
aaaaaaaaaaaaaaaaaa = t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
[a,]
|
[a,]
|
||||||
}" "moreeeeeeeeeeeeeeeeeeee" "test" # comment
|
}" t"moreeeeeeeeeeeeeeeeeeee" t"test" # comment
|
||||||
|
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
[a,]
|
[a,]
|
||||||
}" "moreeeeeeeeeeeeeeeeeeee" "test" # comment
|
}" t"moreeeeeeeeeeeeeeeeeeee" t"test" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
aaaaa[aaaaaaaaaaa] = t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
[a,]
|
[a,]
|
||||||
}" "moreeeeeeeeeeeeeeeeeeee" "test" # comment
|
}" t"moreeeeeeeeeeeeeeeeeeee" t"test" # comment
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
aaaaa[aaaaaaaaaaa] = (t"testeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
[a,]
|
[a,]
|
||||||
}" "moreeeeeeeeeeeeeeeeeeee" "test" # comment
|
}" t"moreeeeeeeeeeeeeeeeeeee" t"test" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Don't inline t-strings that contain commented expressions
|
# Don't inline t-strings that contain commented expressions
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{[
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{[
|
||||||
a # comment
|
a # comment
|
||||||
]}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
]}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{[
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{[
|
||||||
a # comment
|
a # comment
|
||||||
]}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
]}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Don't inline t-strings with multiline debug expressions:
|
# Don't inline t-strings with multiline debug expressions:
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
a=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
a=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a +
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a +
|
||||||
b=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
b=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
||||||
=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
a=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
a=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
||||||
=}" "moreeeeeeeeeeeeeeeeeetest" # comment
|
=}" t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -505,7 +505,7 @@ a = (
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.error(
|
logger.error(
|
||||||
f"Failed to run task {task} for job"
|
f"Failed to run task {task} for job"
|
||||||
f"with id {str(job.id)}" # type: ignore[union-attr]
|
f"with id {str(job.id)}" # type: ignore[union-attr]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -909,7 +909,7 @@ a[aaaaaaa, b] = t"ccccc{expression}ccccccccccccccccccccccccccccccccccc" # comme
|
||||||
# The string gets parenthesized because it, with the inlined comment, exceeds the line length limit.
|
# The string gets parenthesized because it, with the inlined comment, exceeds the line length limit.
|
||||||
a[aaaaaaa, b] = (
|
a[aaaaaaa, b] = (
|
||||||
t"ccccc{expression}ccccccccccc"
|
t"ccccc{expression}ccccccccccc"
|
||||||
"ccccccccccccccccccccccccccccccccccccccccccc"
|
t"ccccccccccccccccccccccccccccccccccccccccccc"
|
||||||
) # comment
|
) # comment
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -925,7 +925,7 @@ a[
|
||||||
aaaaaaa, b
|
aaaaaaa, b
|
||||||
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
].bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
|
||||||
t"ccccc{expression}cccccccccccccccccccccccccccccccc"
|
t"ccccc{expression}cccccccccccccccccccccccccccccccc"
|
||||||
"ccccccccccccccccccccccccccccccc"
|
t"ccccccccccccccccccccccccccccccc"
|
||||||
) # comment
|
) # comment
|
||||||
|
|
||||||
# Don't inline t-strings that contain expressions that are guaranteed to split, e.b. because of a magic trailing comma
|
# Don't inline t-strings that contain expressions that are guaranteed to split, e.b. because of a magic trailing comma
|
||||||
|
|
@ -935,8 +935,8 @@ aaaaaaaaaaaaaaaaaa = (
|
||||||
a,
|
a,
|
||||||
]
|
]
|
||||||
}"
|
}"
|
||||||
"moreeeeeeeeeeeeeeeeeeee"
|
t"moreeeeeeeeeeeeeeeeeeee"
|
||||||
"test"
|
t"test"
|
||||||
) # comment
|
) # comment
|
||||||
|
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
|
|
@ -945,8 +945,8 @@ aaaaaaaaaaaaaaaaaa = (
|
||||||
a,
|
a,
|
||||||
]
|
]
|
||||||
}"
|
}"
|
||||||
"moreeeeeeeeeeeeeeeeeeee"
|
t"moreeeeeeeeeeeeeeeeeeee"
|
||||||
"test" # comment
|
t"test" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
|
|
@ -955,8 +955,8 @@ aaaaa[aaaaaaaaaaa] = (
|
||||||
a,
|
a,
|
||||||
]
|
]
|
||||||
}"
|
}"
|
||||||
"moreeeeeeeeeeeeeeeeeeee"
|
t"moreeeeeeeeeeeeeeeeeeee"
|
||||||
"test"
|
t"test"
|
||||||
) # comment
|
) # comment
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
|
|
@ -965,8 +965,8 @@ aaaaa[aaaaaaaaaaa] = (
|
||||||
a,
|
a,
|
||||||
]
|
]
|
||||||
}"
|
}"
|
||||||
"moreeeeeeeeeeeeeeeeeeee"
|
t"moreeeeeeeeeeeeeeeeeeee"
|
||||||
"test" # comment
|
t"test" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Don't inline t-strings that contain commented expressions
|
# Don't inline t-strings that contain commented expressions
|
||||||
|
|
@ -976,7 +976,7 @@ aaaaaaaaaaaaaaaaaa = (
|
||||||
a # comment
|
a # comment
|
||||||
]
|
]
|
||||||
}"
|
}"
|
||||||
"moreeeeeeeeeeeeeeeeeetest" # comment
|
t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
|
|
@ -985,38 +985,38 @@ aaaaa[aaaaaaaaaaa] = (
|
||||||
a # comment
|
a # comment
|
||||||
]
|
]
|
||||||
}"
|
}"
|
||||||
"moreeeeeeeeeeeeeeeeeetest" # comment
|
t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
# Don't inline t-strings with multiline debug expressions:
|
# Don't inline t-strings with multiline debug expressions:
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
a=}"
|
a=}"
|
||||||
"moreeeeeeeeeeeeeeeeeetest" # comment
|
t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a +
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a +
|
||||||
b=}"
|
b=}"
|
||||||
"moreeeeeeeeeeeeeeeeeetest" # comment
|
t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaaaaaaaaaaaaaaa = (
|
aaaaaaaaaaaaaaaaaa = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
||||||
=}"
|
=}"
|
||||||
"moreeeeeeeeeeeeeeeeeetest" # comment
|
t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{
|
||||||
a=}"
|
a=}"
|
||||||
"moreeeeeeeeeeeeeeeeeetest" # comment
|
t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
aaaaa[aaaaaaaaaaa] = (
|
aaaaa[aaaaaaaaaaa] = (
|
||||||
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
t"testeeeeeeeeeeeeeeeeeeeeeeeee{a
|
||||||
=}"
|
=}"
|
||||||
"moreeeeeeeeeeeeeeeeeetest" # comment
|
t"moreeeeeeeeeeeeeeeeeetest" # comment
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,21 +14,21 @@ rt"Not-so-tricky \"quote"
|
||||||
|
|
||||||
# Regression test for tstrings dropping comments
|
# Regression test for tstrings dropping comments
|
||||||
result_f = (
|
result_f = (
|
||||||
'Traceback (most recent call last):\n'
|
t'Traceback (most recent call last):\n'
|
||||||
t' File "{__file__}", line {lineno_f+5}, in _check_recursive_traceback_display\n'
|
t' File "{__file__}", line {lineno_f+5}, in _check_recursive_traceback_display\n'
|
||||||
' f()\n'
|
t' f()\n'
|
||||||
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
||||||
' f()\n'
|
t' f()\n'
|
||||||
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
||||||
' f()\n'
|
t' f()\n'
|
||||||
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
t' File "{__file__}", line {lineno_f+1}, in f\n'
|
||||||
' f()\n'
|
t' f()\n'
|
||||||
# XXX: The following line changes depending on whether the tests
|
# XXX: The following line changes depending on whether the tests
|
||||||
# are run through the interactive interpreter or with -m
|
# are run through the interactive interpreter or with -m
|
||||||
# It also varies depending on the platform (stack size)
|
# It also varies depending on the platform (stack size)
|
||||||
# Fortunately, we don't care about exactness here, so we use regex
|
# Fortunately, we don't care about exactness here, so we use regex
|
||||||
r' \[Previous line repeated (\d+) more times\]' '\n'
|
rt' \[Previous line repeated (\d+) more times\]' t'\n'
|
||||||
'RecursionError: maximum recursion depth exceeded\n'
|
t'RecursionError: maximum recursion depth exceeded\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ result_f = (
|
||||||
(
|
(
|
||||||
t'{1}'
|
t'{1}'
|
||||||
# comment 1
|
# comment 1
|
||||||
''
|
t''
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
@ -661,7 +661,7 @@ hello {
|
||||||
|
|
||||||
# Implicit concatenated t-string containing quotes
|
# Implicit concatenated t-string containing quotes
|
||||||
_ = (
|
_ = (
|
||||||
'This string should change its quotes to double quotes'
|
t'This string should change its quotes to double quotes'
|
||||||
t'This string uses double quotes in an expression {"it's a quote"}'
|
t'This string uses double quotes in an expression {"it's a quote"}'
|
||||||
t'This t-string does not use any quotes.'
|
t'This t-string does not use any quotes.'
|
||||||
)
|
)
|
||||||
|
|
@ -761,22 +761,22 @@ rt"Not-so-tricky \"quote"
|
||||||
|
|
||||||
# Regression test for tstrings dropping comments
|
# Regression test for tstrings dropping comments
|
||||||
result_f = (
|
result_f = (
|
||||||
"Traceback (most recent call last):\n"
|
t"Traceback (most recent call last):\n"
|
||||||
t' File "{__file__}", line {lineno_f + 5}, in _check_recursive_traceback_display\n'
|
t' File "{__file__}", line {lineno_f + 5}, in _check_recursive_traceback_display\n'
|
||||||
" f()\n"
|
t" f()\n"
|
||||||
t' File "{__file__}", line {lineno_f + 1}, in f\n'
|
t' File "{__file__}", line {lineno_f + 1}, in f\n'
|
||||||
" f()\n"
|
t" f()\n"
|
||||||
t' File "{__file__}", line {lineno_f + 1}, in f\n'
|
t' File "{__file__}", line {lineno_f + 1}, in f\n'
|
||||||
" f()\n"
|
t" f()\n"
|
||||||
t' File "{__file__}", line {lineno_f + 1}, in f\n'
|
t' File "{__file__}", line {lineno_f + 1}, in f\n'
|
||||||
" f()\n"
|
t" f()\n"
|
||||||
# XXX: The following line changes depending on whether the tests
|
# XXX: The following line changes depending on whether the tests
|
||||||
# are run through the interactive interpreter or with -m
|
# are run through the interactive interpreter or with -m
|
||||||
# It also varies depending on the platform (stack size)
|
# It also varies depending on the platform (stack size)
|
||||||
# Fortunately, we don't care about exactness here, so we use regex
|
# Fortunately, we don't care about exactness here, so we use regex
|
||||||
r" \[Previous line repeated (\d+) more times\]"
|
rt" \[Previous line repeated (\d+) more times\]"
|
||||||
"\n"
|
t"\n"
|
||||||
"RecursionError: maximum recursion depth exceeded\n"
|
t"RecursionError: maximum recursion depth exceeded\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -785,7 +785,7 @@ result_f = (
|
||||||
(
|
(
|
||||||
t"{1}"
|
t"{1}"
|
||||||
# comment 1
|
# comment 1
|
||||||
""
|
t""
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
@ -1463,7 +1463,7 @@ hello {
|
||||||
|
|
||||||
# Implicit concatenated t-string containing quotes
|
# Implicit concatenated t-string containing quotes
|
||||||
_ = (
|
_ = (
|
||||||
"This string should change its quotes to double quotes"
|
t"This string should change its quotes to double quotes"
|
||||||
t"This string uses double quotes in an expression {"it's a quote"}"
|
t"This string uses double quotes in an expression {"it's a quote"}"
|
||||||
t"This t-string does not use any quotes."
|
t"This t-string does not use any quotes."
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,3 @@ t"{hey}"
|
||||||
t'{there}'
|
t'{there}'
|
||||||
t"""what's
|
t"""what's
|
||||||
happening?"""
|
happening?"""
|
||||||
"implicitly"t"concatenated"
|
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,3 @@ t"{hey}"
|
||||||
t'{there}'
|
t'{there}'
|
||||||
t"""what's
|
t"""what's
|
||||||
happening?"""
|
happening?"""
|
||||||
"implicitly"t"concatenated"
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ t"{ foo = !s }"
|
||||||
t"{ 1, 2 = }"
|
t"{ 1, 2 = }"
|
||||||
t'{t"{3.1415=:.1f}":*^20}'
|
t'{t"{3.1415=:.1f}":*^20}'
|
||||||
|
|
||||||
{"foo " t"bar {x + y} " "baz": 10}
|
{t"foo " t"bar {x + y} " t"baz": 10}
|
||||||
match foo:
|
match foo:
|
||||||
case "one":
|
case "one":
|
||||||
pass
|
pass
|
||||||
|
|
@ -44,31 +44,18 @@ t"{x=!a}"
|
||||||
t"{x:.3f!r =}"
|
t"{x:.3f!r =}"
|
||||||
t"{x = !r :.3f}"
|
t"{x = !r :.3f}"
|
||||||
t"{x:.3f=!r}"
|
t"{x:.3f=!r}"
|
||||||
"hello" t"{x}"
|
t"hello" t"{x}"
|
||||||
t"{x}" t"{y}"
|
t"{x}" t"{y}"
|
||||||
t"{x}" "world"
|
t"{x}" t"world"
|
||||||
t"Invalid args in command: {command, *args}"
|
t"Invalid args in command: {command, *args}"
|
||||||
"foo" t"{x}" "bar"
|
t"foo" t"{x}" t"bar"
|
||||||
(
|
(
|
||||||
t"a"
|
t"a"
|
||||||
t"b"
|
t"b"
|
||||||
"c"
|
t"c"
|
||||||
rt"d"
|
rt"d"
|
||||||
fr"e"
|
tr"e"
|
||||||
)
|
)
|
||||||
|
|
||||||
# With unicode strings
|
|
||||||
u"foo" t"{bar}" "baz" " some"
|
|
||||||
"foo" t"{bar}" u"baz" " some"
|
|
||||||
"foo" t"{bar}" "baz" u" some"
|
|
||||||
u"foo" t"bar {baz} really" u"bar" "no"
|
|
||||||
|
|
||||||
|
|
||||||
# With f-strings
|
|
||||||
f"{this}" t"{that}"
|
|
||||||
t"{this}"f"{that}"
|
|
||||||
t"{this}" "that" f"{other}"
|
|
||||||
f"one {this} two" "that" t"three {other} four"
|
|
||||||
|
|
||||||
# Nesting
|
# Nesting
|
||||||
t"{f"{t"{this}"}"}"
|
t"{f"{t"{this}"}"}"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use std::cmp::Ordering;
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
|
|
@ -1256,7 +1255,6 @@ impl<'src> Parser<'src> {
|
||||||
// t'{there}'
|
// t'{there}'
|
||||||
// t"""what's
|
// t"""what's
|
||||||
// happening?"""
|
// happening?"""
|
||||||
// "implicitly"t"concatenated"
|
|
||||||
|
|
||||||
// test_err template_strings_py313
|
// test_err template_strings_py313
|
||||||
// # parse_options: {"target-version": "3.13"}
|
// # parse_options: {"target-version": "3.13"}
|
||||||
|
|
@ -1264,7 +1262,6 @@ impl<'src> Parser<'src> {
|
||||||
// t'{there}'
|
// t'{there}'
|
||||||
// t"""what's
|
// t"""what's
|
||||||
// happening?"""
|
// happening?"""
|
||||||
// "implicitly"t"concatenated"
|
|
||||||
let string_type = StringType::TString(
|
let string_type = StringType::TString(
|
||||||
self.parse_interpolated_string(InterpolatedStringKind::TString)
|
self.parse_interpolated_string(InterpolatedStringKind::TString)
|
||||||
.into(),
|
.into(),
|
||||||
|
|
@ -1281,7 +1278,7 @@ impl<'src> Parser<'src> {
|
||||||
|
|
||||||
match strings.len() {
|
match strings.len() {
|
||||||
// This is not possible as the function was called by matching against a
|
// This is not possible as the function was called by matching against a
|
||||||
// `String` or `FStringStart` token.
|
// `String`, `FStringStart`, or `TStringStart` token.
|
||||||
0 => unreachable!("Expected to parse at least one string"),
|
0 => unreachable!("Expected to parse at least one string"),
|
||||||
// We need a owned value, hence the `pop` here.
|
// We need a owned value, hence the `pop` here.
|
||||||
1 => match strings.pop().unwrap() {
|
1 => match strings.pop().unwrap() {
|
||||||
|
|
@ -1322,58 +1319,84 @@ impl<'src> Parser<'src> {
|
||||||
) -> Expr {
|
) -> Expr {
|
||||||
assert!(strings.len() > 1);
|
assert!(strings.len() > 1);
|
||||||
|
|
||||||
let mut has_tstring = false;
|
|
||||||
let mut has_fstring = false;
|
let mut has_fstring = false;
|
||||||
let mut byte_literal_count = 0;
|
let mut byte_literal_count = 0;
|
||||||
|
let mut tstring_count = 0;
|
||||||
for string in &strings {
|
for string in &strings {
|
||||||
match string {
|
match string {
|
||||||
StringType::FString(_) => has_fstring = true,
|
StringType::FString(_) => has_fstring = true,
|
||||||
StringType::TString(_) => has_tstring = true,
|
StringType::TString(_) => tstring_count += 1,
|
||||||
StringType::Bytes(_) => byte_literal_count += 1,
|
StringType::Bytes(_) => byte_literal_count += 1,
|
||||||
StringType::Str(_) => {}
|
StringType::Str(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let has_bytes = byte_literal_count > 0;
|
let has_bytes = byte_literal_count > 0;
|
||||||
|
let has_tstring = tstring_count > 0;
|
||||||
|
|
||||||
if has_bytes {
|
if has_bytes {
|
||||||
match byte_literal_count.cmp(&strings.len()) {
|
if byte_literal_count < strings.len() {
|
||||||
Ordering::Less => {
|
// TODO(dhruvmanila): This is not an ideal recovery because the parser
|
||||||
// TODO(dhruvmanila): This is not an ideal recovery because the parser
|
// replaces the byte literals with an invalid string literal node. Any
|
||||||
// replaces the byte literals with an invalid string literal node. Any
|
// downstream tools can extract the raw bytes from the range.
|
||||||
// downstream tools can extract the raw bytes from the range.
|
//
|
||||||
//
|
// We could convert the node into a string and mark it as invalid
|
||||||
// We could convert the node into a string and mark it as invalid
|
// and would be clever to mark the type which is fewer in quantity.
|
||||||
// and would be clever to mark the type which is fewer in quantity.
|
|
||||||
|
|
||||||
// test_err mixed_bytes_and_non_bytes_literals
|
// test_err mixed_bytes_and_non_bytes_literals
|
||||||
// 'first' b'second'
|
// 'first' b'second'
|
||||||
// f'first' b'second'
|
// f'first' b'second'
|
||||||
// 'first' f'second' b'third'
|
// 'first' f'second' b'third'
|
||||||
self.add_error(
|
self.add_error(
|
||||||
ParseErrorType::OtherError(
|
ParseErrorType::OtherError(
|
||||||
"Bytes literal cannot be mixed with non-bytes literals".to_string(),
|
"Bytes literal cannot be mixed with non-bytes literals".to_string(),
|
||||||
),
|
),
|
||||||
range,
|
range,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Only construct a byte expression if all the literals are bytes
|
// Only construct a byte expression if all the literals are bytes
|
||||||
// otherwise, we'll try either string, t-string, or f-string. This is to retain
|
// otherwise, we'll try either string, t-string, or f-string. This is to retain
|
||||||
// as much information as possible.
|
// as much information as possible.
|
||||||
Ordering::Equal => {
|
else {
|
||||||
let mut values = Vec::with_capacity(strings.len());
|
let mut values = Vec::with_capacity(strings.len());
|
||||||
for string in strings {
|
for string in strings {
|
||||||
values.push(match string {
|
values.push(match string {
|
||||||
StringType::Bytes(value) => value,
|
StringType::Bytes(value) => value,
|
||||||
_ => unreachable!("Expected `StringType::Bytes`"),
|
_ => unreachable!("Expected `StringType::Bytes`"),
|
||||||
});
|
|
||||||
}
|
|
||||||
return Expr::from(ast::ExprBytesLiteral {
|
|
||||||
value: ast::BytesLiteralValue::concatenated(values),
|
|
||||||
range,
|
|
||||||
node_index: AtomicNodeIndex::dummy(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Ordering::Greater => unreachable!(),
|
return Expr::from(ast::ExprBytesLiteral {
|
||||||
|
value: ast::BytesLiteralValue::concatenated(values),
|
||||||
|
range,
|
||||||
|
node_index: AtomicNodeIndex::dummy(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if has_tstring {
|
||||||
|
if tstring_count < strings.len() {
|
||||||
|
self.add_error(
|
||||||
|
ParseErrorType::OtherError(
|
||||||
|
"cannot mix t-string literals with string or bytes literals".to_string(),
|
||||||
|
),
|
||||||
|
range,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Only construct a t-string expression if all the literals are t-strings
|
||||||
|
// otherwise, we'll try either string or f-string. This is to retain
|
||||||
|
// as much information as possible.
|
||||||
|
else {
|
||||||
|
let mut values = Vec::with_capacity(strings.len());
|
||||||
|
for string in strings {
|
||||||
|
values.push(match string {
|
||||||
|
StringType::TString(value) => value,
|
||||||
|
_ => unreachable!("Expected `StringType::TString`"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Expr::from(ast::ExprTString {
|
||||||
|
value: ast::TStringValue::concatenated(values),
|
||||||
|
range,
|
||||||
|
node_index: AtomicNodeIndex::dummy(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1414,36 +1437,17 @@ impl<'src> Parser<'src> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if has_tstring {
|
|
||||||
let mut parts = Vec::with_capacity(strings.len());
|
|
||||||
for string in strings {
|
|
||||||
match string {
|
|
||||||
StringType::TString(tstring) => parts.push(ast::TStringPart::TString(tstring)),
|
|
||||||
StringType::FString(fstring) => {
|
|
||||||
parts.push(ruff_python_ast::TStringPart::FString(fstring));
|
|
||||||
}
|
|
||||||
StringType::Str(string) => parts.push(ast::TStringPart::Literal(string)),
|
|
||||||
StringType::Bytes(bytes) => parts.push(ast::TStringPart::Literal(
|
|
||||||
ast::StringLiteral::invalid(bytes.range()),
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Expr::from(ast::ExprTString {
|
|
||||||
value: ast::TStringValue::concatenated(parts),
|
|
||||||
range,
|
|
||||||
node_index: AtomicNodeIndex::dummy(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut parts = Vec::with_capacity(strings.len());
|
let mut parts = Vec::with_capacity(strings.len());
|
||||||
for string in strings {
|
for string in strings {
|
||||||
match string {
|
match string {
|
||||||
StringType::FString(fstring) => parts.push(ast::FStringPart::FString(fstring)),
|
StringType::FString(fstring) => parts.push(ast::FStringPart::FString(fstring)),
|
||||||
StringType::TString(_) => {
|
|
||||||
unreachable!("expected no tstring parts by this point")
|
|
||||||
}
|
|
||||||
StringType::Str(string) => parts.push(ast::FStringPart::Literal(string)),
|
StringType::Str(string) => parts.push(ast::FStringPart::Literal(string)),
|
||||||
|
// Bytes and Template strings are invalid at this point
|
||||||
|
// and stored as invalid string literal parts in the
|
||||||
|
// f-string
|
||||||
|
StringType::TString(tstring) => parts.push(ast::FStringPart::Literal(
|
||||||
|
ast::StringLiteral::invalid(tstring.range()),
|
||||||
|
)),
|
||||||
StringType::Bytes(bytes) => parts.push(ast::FStringPart::Literal(
|
StringType::Bytes(bytes) => parts.push(ast::FStringPart::Literal(
|
||||||
ast::StringLiteral::invalid(bytes.range()),
|
ast::StringLiteral::invalid(bytes.range()),
|
||||||
)),
|
)),
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,16 @@ expression: suite
|
||||||
range: 0..3,
|
range: 0..3,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..3,
|
||||||
range: 0..3,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [],
|
||||||
elements: [],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_python_parser/src/string.rs
|
|
||||||
expression: suite
|
|
||||||
---
|
|
||||||
[
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..18,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..18,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
FString(
|
|
||||||
FString {
|
|
||||||
range: 0..9,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 2..8,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "Hello ",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: FStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 10..18,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 12..17,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "world",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_parser/src/string.rs
|
||||||
|
expression: suite
|
||||||
|
---
|
||||||
|
ParseError {
|
||||||
|
error: OtherError(
|
||||||
|
"cannot mix t-string literals with string or bytes literals",
|
||||||
|
),
|
||||||
|
location: 0..18,
|
||||||
|
}
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_python_parser/src/string.rs
|
|
||||||
expression: suite
|
|
||||||
---
|
|
||||||
[
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..22,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..22,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
FString(
|
|
||||||
FString {
|
|
||||||
range: 0..9,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 2..8,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "Hello ",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: FStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 10..18,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 12..17,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "world",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 19..22,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "!",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_parser/src/string.rs
|
||||||
|
expression: suite
|
||||||
|
---
|
||||||
|
ParseError {
|
||||||
|
error: OtherError(
|
||||||
|
"cannot mix t-string literals with string or bytes literals",
|
||||||
|
),
|
||||||
|
location: 0..22,
|
||||||
|
}
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_python_parser/src/string.rs
|
|
||||||
expression: suite
|
|
||||||
---
|
|
||||||
[
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..17,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..17,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 0..8,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "Hello ",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 9..17,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 11..16,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "world",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_parser/src/string.rs
|
||||||
|
expression: suite
|
||||||
|
---
|
||||||
|
ParseError {
|
||||||
|
error: OtherError(
|
||||||
|
"cannot mix t-string literals with string or bytes literals",
|
||||||
|
),
|
||||||
|
location: 0..17,
|
||||||
|
}
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_python_parser/src/string.rs
|
|
||||||
expression: suite
|
|
||||||
---
|
|
||||||
[
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..17,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..17,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 0..8,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "Hello ",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 9..17,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 11..16,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "world",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_parser/src/string.rs
|
||||||
|
expression: suite
|
||||||
|
---
|
||||||
|
ParseError {
|
||||||
|
error: OtherError(
|
||||||
|
"cannot mix t-string literals with string or bytes literals",
|
||||||
|
),
|
||||||
|
location: 0..17,
|
||||||
|
}
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_python_parser/src/string.rs
|
|
||||||
expression: suite
|
|
||||||
---
|
|
||||||
[
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..22,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..22,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 0..8,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "Hello ",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 9..22,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 11..16,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "world",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Interpolation(
|
|
||||||
InterpolatedElement {
|
|
||||||
range: 16..21,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
expression: StringLiteral(
|
|
||||||
ExprStringLiteral {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 17..20,
|
|
||||||
value: StringLiteralValue {
|
|
||||||
inner: Single(
|
|
||||||
StringLiteral {
|
|
||||||
range: 17..20,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "!",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
debug_text: None,
|
|
||||||
conversion: None,
|
|
||||||
format_spec: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_parser/src/string.rs
|
||||||
|
expression: suite
|
||||||
|
---
|
||||||
|
ParseError {
|
||||||
|
error: OtherError(
|
||||||
|
"cannot mix t-string literals with string or bytes literals",
|
||||||
|
),
|
||||||
|
location: 0..22,
|
||||||
|
}
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_python_parser/src/string.rs
|
|
||||||
expression: suite
|
|
||||||
---
|
|
||||||
[
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..31,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..31,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 0..8,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "Hello ",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 9..22,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 11..16,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "world",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Interpolation(
|
|
||||||
InterpolatedElement {
|
|
||||||
range: 16..21,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
expression: StringLiteral(
|
|
||||||
ExprStringLiteral {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 17..20,
|
|
||||||
value: StringLiteralValue {
|
|
||||||
inner: Single(
|
|
||||||
StringLiteral {
|
|
||||||
range: 17..20,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "!",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
debug_text: None,
|
|
||||||
conversion: None,
|
|
||||||
format_spec: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 23..31,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "again!",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_parser/src/string.rs
|
||||||
|
expression: suite
|
||||||
|
---
|
||||||
|
ParseError {
|
||||||
|
error: OtherError(
|
||||||
|
"cannot mix t-string literals with string or bytes literals",
|
||||||
|
),
|
||||||
|
location: 0..31,
|
||||||
|
}
|
||||||
|
|
@ -13,60 +13,58 @@ expression: suite
|
||||||
range: 0..18,
|
range: 0..18,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..18,
|
||||||
range: 0..18,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..5,
|
||||||
range: 2..5,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..4,
|
||||||
range: 3..4,
|
id: Name("a"),
|
||||||
id: Name("a"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 5..10,
|
||||||
range: 5..10,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 7..8,
|
||||||
range: 7..8,
|
id: Name("b"),
|
||||||
id: Name("b"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 10..17,
|
||||||
range: 10..17,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "{foo}",
|
||||||
value: "{foo}",
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,57 +13,55 @@ expression: suite
|
||||||
range: 0..13,
|
range: 0..13,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..13,
|
||||||
range: 0..13,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..12,
|
||||||
range: 2..12,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Compare(
|
||||||
expression: Compare(
|
ExprCompare {
|
||||||
ExprCompare {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..11,
|
||||||
range: 3..11,
|
left: NumberLiteral(
|
||||||
left: NumberLiteral(
|
ExprNumberLiteral {
|
||||||
|
node_index: AtomicNodeIndex(..),
|
||||||
|
range: 3..5,
|
||||||
|
value: Int(
|
||||||
|
42,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ops: [
|
||||||
|
Eq,
|
||||||
|
],
|
||||||
|
comparators: [
|
||||||
|
NumberLiteral(
|
||||||
ExprNumberLiteral {
|
ExprNumberLiteral {
|
||||||
node_index: AtomicNodeIndex(..),
|
node_index: AtomicNodeIndex(..),
|
||||||
range: 3..5,
|
range: 9..11,
|
||||||
value: Int(
|
value: Int(
|
||||||
42,
|
42,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ops: [
|
],
|
||||||
Eq,
|
},
|
||||||
],
|
),
|
||||||
comparators: [
|
debug_text: None,
|
||||||
NumberLiteral(
|
conversion: None,
|
||||||
ExprNumberLiteral {
|
format_spec: None,
|
||||||
node_index: AtomicNodeIndex(..),
|
},
|
||||||
range: 9..11,
|
),
|
||||||
value: Int(
|
],
|
||||||
42,
|
flags: TStringFlags {
|
||||||
),
|
quote_style: Double,
|
||||||
},
|
prefix: Regular,
|
||||||
),
|
triple_quoted: false,
|
||||||
],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
debug_text: None,
|
|
||||||
conversion: None,
|
|
||||||
format_spec: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,87 +13,85 @@ expression: suite
|
||||||
range: 0..16,
|
range: 0..16,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..16,
|
||||||
range: 0..16,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..15,
|
||||||
range: 2..15,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..6,
|
||||||
range: 3..6,
|
id: Name("foo"),
|
||||||
id: Name("foo"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: Some(
|
||||||
format_spec: Some(
|
InterpolatedStringFormatSpec {
|
||||||
InterpolatedStringFormatSpec {
|
range: 7..14,
|
||||||
range: 7..14,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 7..14,
|
||||||
range: 7..14,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: StringLiteral(
|
||||||
expression: StringLiteral(
|
ExprStringLiteral {
|
||||||
ExprStringLiteral {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 8..13,
|
||||||
range: 8..13,
|
value: StringLiteralValue {
|
||||||
value: StringLiteralValue {
|
inner: Concatenated(
|
||||||
inner: Concatenated(
|
ConcatenatedStringLiteral {
|
||||||
ConcatenatedStringLiteral {
|
strings: [
|
||||||
strings: [
|
StringLiteral {
|
||||||
StringLiteral {
|
range: 8..10,
|
||||||
range: 8..10,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "",
|
||||||
value: "",
|
flags: StringLiteralFlags {
|
||||||
flags: StringLiteralFlags {
|
quote_style: Single,
|
||||||
quote_style: Single,
|
prefix: Empty,
|
||||||
prefix: Empty,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
StringLiteral {
|
},
|
||||||
range: 11..13,
|
StringLiteral {
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 11..13,
|
||||||
value: "",
|
node_index: AtomicNodeIndex(..),
|
||||||
flags: StringLiteralFlags {
|
value: "",
|
||||||
quote_style: Single,
|
flags: StringLiteralFlags {
|
||||||
prefix: Empty,
|
quote_style: Single,
|
||||||
triple_quoted: false,
|
prefix: Empty,
|
||||||
},
|
triple_quoted: false,
|
||||||
},
|
},
|
||||||
],
|
},
|
||||||
value: "",
|
],
|
||||||
},
|
value: "",
|
||||||
),
|
},
|
||||||
},
|
),
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
debug_text: None,
|
),
|
||||||
conversion: None,
|
debug_text: None,
|
||||||
format_spec: None,
|
conversion: None,
|
||||||
},
|
format_spec: None,
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
},
|
],
|
||||||
),
|
},
|
||||||
},
|
),
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
flags: TStringFlags {
|
],
|
||||||
quote_style: Double,
|
flags: TStringFlags {
|
||||||
prefix: Regular,
|
quote_style: Double,
|
||||||
triple_quoted: false,
|
prefix: Regular,
|
||||||
},
|
triple_quoted: false,
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,60 +13,58 @@ expression: suite
|
||||||
range: 0..15,
|
range: 0..15,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..15,
|
||||||
range: 0..15,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..14,
|
||||||
range: 2..14,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..6,
|
||||||
range: 3..6,
|
id: Name("foo"),
|
||||||
id: Name("foo"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: Some(
|
||||||
format_spec: Some(
|
InterpolatedStringFormatSpec {
|
||||||
InterpolatedStringFormatSpec {
|
range: 7..13,
|
||||||
range: 7..13,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 7..13,
|
||||||
range: 7..13,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 8..12,
|
||||||
range: 8..12,
|
id: Name("spec"),
|
||||||
id: Name("spec"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
},
|
||||||
},
|
),
|
||||||
),
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,72 +13,70 @@ expression: suite
|
||||||
range: 0..13,
|
range: 0..13,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..13,
|
||||||
range: 0..13,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..12,
|
||||||
range: 2..12,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..6,
|
||||||
range: 3..6,
|
id: Name("foo"),
|
||||||
id: Name("foo"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: Some(
|
||||||
format_spec: Some(
|
InterpolatedStringFormatSpec {
|
||||||
InterpolatedStringFormatSpec {
|
range: 7..11,
|
||||||
range: 7..11,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 7..11,
|
||||||
range: 7..11,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: StringLiteral(
|
||||||
expression: StringLiteral(
|
ExprStringLiteral {
|
||||||
ExprStringLiteral {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 8..10,
|
||||||
range: 8..10,
|
value: StringLiteralValue {
|
||||||
value: StringLiteralValue {
|
inner: Single(
|
||||||
inner: Single(
|
StringLiteral {
|
||||||
StringLiteral {
|
range: 8..10,
|
||||||
range: 8..10,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "",
|
||||||
value: "",
|
flags: StringLiteralFlags {
|
||||||
flags: StringLiteralFlags {
|
quote_style: Single,
|
||||||
quote_style: Single,
|
prefix: Empty,
|
||||||
prefix: Empty,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
},
|
),
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
debug_text: None,
|
),
|
||||||
conversion: None,
|
debug_text: None,
|
||||||
format_spec: None,
|
conversion: None,
|
||||||
},
|
format_spec: None,
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
},
|
],
|
||||||
),
|
},
|
||||||
},
|
),
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
flags: TStringFlags {
|
],
|
||||||
quote_style: Double,
|
flags: TStringFlags {
|
||||||
prefix: Regular,
|
quote_style: Double,
|
||||||
triple_quoted: false,
|
prefix: Regular,
|
||||||
},
|
triple_quoted: false,
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,57 +13,55 @@ expression: suite
|
||||||
range: 0..11,
|
range: 0..11,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..11,
|
||||||
range: 0..11,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..10,
|
||||||
range: 2..10,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Compare(
|
||||||
expression: Compare(
|
ExprCompare {
|
||||||
ExprCompare {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..9,
|
||||||
range: 3..9,
|
left: NumberLiteral(
|
||||||
left: NumberLiteral(
|
ExprNumberLiteral {
|
||||||
|
node_index: AtomicNodeIndex(..),
|
||||||
|
range: 3..4,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ops: [
|
||||||
|
NotEq,
|
||||||
|
],
|
||||||
|
comparators: [
|
||||||
|
NumberLiteral(
|
||||||
ExprNumberLiteral {
|
ExprNumberLiteral {
|
||||||
node_index: AtomicNodeIndex(..),
|
node_index: AtomicNodeIndex(..),
|
||||||
range: 3..4,
|
range: 8..9,
|
||||||
value: Int(
|
value: Int(
|
||||||
1,
|
2,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ops: [
|
],
|
||||||
NotEq,
|
},
|
||||||
],
|
),
|
||||||
comparators: [
|
debug_text: None,
|
||||||
NumberLiteral(
|
conversion: None,
|
||||||
ExprNumberLiteral {
|
format_spec: None,
|
||||||
node_index: AtomicNodeIndex(..),
|
},
|
||||||
range: 8..9,
|
),
|
||||||
value: Int(
|
],
|
||||||
2,
|
flags: TStringFlags {
|
||||||
),
|
quote_style: Double,
|
||||||
},
|
prefix: Regular,
|
||||||
),
|
triple_quoted: false,
|
||||||
],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
debug_text: None,
|
|
||||||
conversion: None,
|
|
||||||
format_spec: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,50 +13,48 @@ expression: suite
|
||||||
range: 0..13,
|
range: 0..13,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..13,
|
||||||
range: 0..13,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..12,
|
||||||
range: 2..12,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..6,
|
||||||
range: 3..6,
|
id: Name("foo"),
|
||||||
id: Name("foo"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: Some(
|
||||||
format_spec: Some(
|
InterpolatedStringFormatSpec {
|
||||||
InterpolatedStringFormatSpec {
|
range: 7..11,
|
||||||
range: 7..11,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 7..11,
|
||||||
range: 7..11,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "spec",
|
||||||
value: "spec",
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
},
|
||||||
},
|
),
|
||||||
),
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,41 +13,39 @@ expression: suite
|
||||||
range: 0..10,
|
range: 0..10,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..10,
|
||||||
range: 0..10,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..9,
|
||||||
range: 2..9,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..4,
|
||||||
range: 3..4,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: Some(
|
||||||
debug_text: Some(
|
DebugText {
|
||||||
DebugText {
|
leading: "",
|
||||||
leading: "",
|
trailing: " =",
|
||||||
trailing: " =",
|
},
|
||||||
},
|
),
|
||||||
),
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,41 +13,39 @@ expression: suite
|
||||||
range: 0..10,
|
range: 0..10,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..10,
|
||||||
range: 0..10,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..9,
|
||||||
range: 2..9,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..4,
|
||||||
range: 3..4,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: Some(
|
||||||
debug_text: Some(
|
DebugText {
|
||||||
DebugText {
|
leading: "",
|
||||||
leading: "",
|
trailing: "= ",
|
||||||
trailing: "= ",
|
},
|
||||||
},
|
),
|
||||||
),
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,35 +13,33 @@ expression: suite
|
||||||
range: 0..10,
|
range: 0..10,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..10,
|
||||||
range: 0..10,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..9,
|
||||||
range: 2..9,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Yield(
|
||||||
expression: Yield(
|
ExprYield {
|
||||||
ExprYield {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..8,
|
||||||
range: 3..8,
|
value: None,
|
||||||
value: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_python_parser/src/string.rs
|
|
||||||
expression: suite
|
|
||||||
---
|
|
||||||
[
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..18,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..18,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 0..9,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "Hello ",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Unicode,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 10..18,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 12..17,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "world",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_parser/src/string.rs
|
||||||
|
expression: suite
|
||||||
|
---
|
||||||
|
ParseError {
|
||||||
|
error: OtherError(
|
||||||
|
"cannot mix t-string literals with string or bytes literals",
|
||||||
|
),
|
||||||
|
location: 0..18,
|
||||||
|
}
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_python_parser/src/string.rs
|
|
||||||
expression: suite
|
|
||||||
---
|
|
||||||
[
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..22,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 0..22,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 0..9,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "Hello ",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Unicode,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 10..18,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 12..17,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "world",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 19..22,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "!",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Single,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_parser/src/string.rs
|
||||||
|
expression: suite
|
||||||
|
---
|
||||||
|
ParseError {
|
||||||
|
error: OtherError(
|
||||||
|
"cannot mix t-string literals with string or bytes literals",
|
||||||
|
),
|
||||||
|
location: 0..22,
|
||||||
|
}
|
||||||
|
|
@ -13,38 +13,36 @@ expression: suite
|
||||||
range: 0..7,
|
range: 0..7,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..7,
|
||||||
range: 0..7,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 3..6,
|
||||||
range: 3..6,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 4..5,
|
||||||
range: 4..5,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Raw {
|
|
||||||
uppercase_r: false,
|
|
||||||
},
|
},
|
||||||
triple_quoted: false,
|
),
|
||||||
|
],
|
||||||
|
flags: TStringFlags {
|
||||||
|
quote_style: Double,
|
||||||
|
prefix: Raw {
|
||||||
|
uppercase_r: false,
|
||||||
},
|
},
|
||||||
|
triple_quoted: false,
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,38 +13,36 @@ expression: suite
|
||||||
range: 0..11,
|
range: 0..11,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..11,
|
||||||
range: 0..11,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 5..8,
|
||||||
range: 5..8,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 6..7,
|
||||||
range: 6..7,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Raw {
|
|
||||||
uppercase_r: false,
|
|
||||||
},
|
},
|
||||||
triple_quoted: true,
|
),
|
||||||
|
],
|
||||||
|
flags: TStringFlags {
|
||||||
|
quote_style: Double,
|
||||||
|
prefix: Raw {
|
||||||
|
uppercase_r: false,
|
||||||
},
|
},
|
||||||
|
triple_quoted: true,
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,74 +13,72 @@ expression: suite
|
||||||
range: 0..22,
|
range: 0..22,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..22,
|
||||||
range: 0..22,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 2..5,
|
||||||
range: 2..5,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "aaa",
|
||||||
value: "aaa",
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 5..10,
|
||||||
range: 5..10,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 6..9,
|
||||||
range: 6..9,
|
id: Name("bbb"),
|
||||||
id: Name("bbb"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 10..13,
|
||||||
range: 10..13,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "ccc",
|
||||||
value: "ccc",
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 13..18,
|
||||||
range: 13..18,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 14..17,
|
||||||
range: 14..17,
|
id: Name("ddd"),
|
||||||
id: Name("ddd"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 18..21,
|
||||||
range: 18..21,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "eee",
|
||||||
value: "eee",
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,43 +13,41 @@ expression: suite
|
||||||
range: 0..8,
|
range: 0..8,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..8,
|
||||||
range: 0..8,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 2..4,
|
||||||
range: 2..4,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "\\",
|
||||||
value: "\\",
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 4..7,
|
||||||
range: 4..7,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 5..6,
|
||||||
range: 5..6,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,43 +13,41 @@ expression: suite
|
||||||
range: 0..8,
|
range: 0..8,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..8,
|
||||||
range: 0..8,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 2..4,
|
||||||
range: 2..4,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "\n",
|
||||||
value: "\n",
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 4..7,
|
||||||
range: 4..7,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 5..6,
|
||||||
range: 5..6,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,45 +13,43 @@ expression: suite
|
||||||
range: 0..9,
|
range: 0..9,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..9,
|
||||||
range: 0..9,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 3..5,
|
||||||
range: 3..5,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "\\\n",
|
||||||
value: "\\\n",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Interpolation(
|
|
||||||
InterpolatedElement {
|
|
||||||
range: 5..8,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
expression: Name(
|
|
||||||
ExprName {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 6..7,
|
|
||||||
id: Name("x"),
|
|
||||||
ctx: Load,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
debug_text: None,
|
|
||||||
conversion: None,
|
|
||||||
format_spec: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Raw {
|
|
||||||
uppercase_r: false,
|
|
||||||
},
|
},
|
||||||
triple_quoted: false,
|
),
|
||||||
|
Interpolation(
|
||||||
|
InterpolatedElement {
|
||||||
|
range: 5..8,
|
||||||
|
node_index: AtomicNodeIndex(..),
|
||||||
|
expression: Name(
|
||||||
|
ExprName {
|
||||||
|
node_index: AtomicNodeIndex(..),
|
||||||
|
range: 6..7,
|
||||||
|
id: Name("x"),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
debug_text: None,
|
||||||
|
conversion: None,
|
||||||
|
format_spec: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
flags: TStringFlags {
|
||||||
|
quote_style: Double,
|
||||||
|
prefix: Raw {
|
||||||
|
uppercase_r: false,
|
||||||
},
|
},
|
||||||
|
triple_quoted: false,
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,41 +13,39 @@ expression: suite
|
||||||
range: 0..10,
|
range: 0..10,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..10,
|
||||||
range: 0..10,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..9,
|
||||||
range: 2..9,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..7,
|
||||||
range: 3..7,
|
id: Name("user"),
|
||||||
id: Name("user"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: Some(
|
||||||
debug_text: Some(
|
DebugText {
|
||||||
DebugText {
|
leading: "",
|
||||||
leading: "",
|
trailing: "=",
|
||||||
trailing: "=",
|
},
|
||||||
},
|
),
|
||||||
),
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,77 +13,75 @@ expression: suite
|
||||||
range: 0..38,
|
range: 0..38,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..38,
|
||||||
range: 0..38,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 2..6,
|
||||||
range: 2..6,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "mix ",
|
||||||
value: "mix ",
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 6..13,
|
||||||
range: 6..13,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 7..11,
|
||||||
range: 7..11,
|
id: Name("user"),
|
||||||
id: Name("user"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: Some(
|
||||||
debug_text: Some(
|
DebugText {
|
||||||
DebugText {
|
leading: "",
|
||||||
leading: "",
|
trailing: "=",
|
||||||
trailing: "=",
|
},
|
||||||
},
|
),
|
||||||
),
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 13..28,
|
||||||
range: 13..28,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: " with text and ",
|
||||||
value: " with text and ",
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 28..37,
|
||||||
range: 28..37,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 29..35,
|
||||||
range: 29..35,
|
id: Name("second"),
|
||||||
id: Name("second"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: Some(
|
||||||
debug_text: Some(
|
DebugText {
|
||||||
DebugText {
|
leading: "",
|
||||||
leading: "",
|
trailing: "=",
|
||||||
trailing: "=",
|
},
|
||||||
},
|
),
|
||||||
),
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,55 +13,53 @@ expression: suite
|
||||||
range: 0..14,
|
range: 0..14,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..14,
|
||||||
range: 0..14,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 2..13,
|
||||||
range: 2..13,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 3..7,
|
||||||
range: 3..7,
|
id: Name("user"),
|
||||||
id: Name("user"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: Some(
|
||||||
debug_text: Some(
|
DebugText {
|
||||||
DebugText {
|
leading: "",
|
||||||
leading: "",
|
trailing: "=",
|
||||||
trailing: "=",
|
},
|
||||||
},
|
),
|
||||||
),
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: Some(
|
||||||
format_spec: Some(
|
InterpolatedStringFormatSpec {
|
||||||
InterpolatedStringFormatSpec {
|
range: 9..12,
|
||||||
range: 9..12,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 9..12,
|
||||||
range: 9..12,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: ">10",
|
||||||
value: ">10",
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
},
|
||||||
},
|
),
|
||||||
),
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,43 +13,41 @@ expression: suite
|
||||||
range: 0..11,
|
range: 0..11,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 0..11,
|
||||||
range: 0..11,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 4..5,
|
||||||
range: 4..5,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "\n",
|
||||||
value: "\n",
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 5..8,
|
||||||
range: 5..8,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 6..7,
|
||||||
range: 6..7,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: true,
|
||||||
triple_quoted: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -850,58 +850,58 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_t_string_concat_1() {
|
fn test_parse_t_string_concat_1_error() {
|
||||||
let source = "'Hello ' t'world'";
|
let source = "'Hello ' t'world'";
|
||||||
let suite = parse_suite(source).unwrap();
|
let suite = parse_suite(source).unwrap_err();
|
||||||
insta::assert_debug_snapshot!(suite);
|
insta::assert_debug_snapshot!(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_t_string_concat_2() {
|
fn test_parse_t_string_concat_2_error() {
|
||||||
let source = "'Hello ' t'world'";
|
let source = "'Hello ' t'world'";
|
||||||
let suite = parse_suite(source).unwrap();
|
let suite = parse_suite(source).unwrap_err();
|
||||||
insta::assert_debug_snapshot!(suite);
|
insta::assert_debug_snapshot!(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_t_string_concat_3() {
|
fn test_parse_t_string_concat_3_error() {
|
||||||
let source = "'Hello ' t'world{\"!\"}'";
|
let source = "'Hello ' t'world{\"!\"}'";
|
||||||
let suite = parse_suite(source).unwrap();
|
let suite = parse_suite(source).unwrap_err();
|
||||||
insta::assert_debug_snapshot!(suite);
|
insta::assert_debug_snapshot!(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_t_string_concat_4() {
|
fn test_parse_t_string_concat_4_error() {
|
||||||
let source = "'Hello ' t'world{\"!\"}' 'again!'";
|
let source = "'Hello ' t'world{\"!\"}' 'again!'";
|
||||||
let suite = parse_suite(source).unwrap();
|
let suite = parse_suite(source).unwrap_err();
|
||||||
insta::assert_debug_snapshot!(suite);
|
insta::assert_debug_snapshot!(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_u_t_string_concat_1() {
|
fn test_parse_u_t_string_concat_1_error() {
|
||||||
let source = "u'Hello ' t'world'";
|
let source = "u'Hello ' t'world'";
|
||||||
let suite = parse_suite(source).unwrap();
|
let suite = parse_suite(source).unwrap_err();
|
||||||
insta::assert_debug_snapshot!(suite);
|
insta::assert_debug_snapshot!(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_u_t_string_concat_2() {
|
fn test_parse_u_t_string_concat_2_error() {
|
||||||
let source = "u'Hello ' t'world' '!'";
|
let source = "u'Hello ' t'world' '!'";
|
||||||
let suite = parse_suite(source).unwrap();
|
let suite = parse_suite(source).unwrap_err();
|
||||||
insta::assert_debug_snapshot!(suite);
|
insta::assert_debug_snapshot!(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_f_t_string_concat_1() {
|
fn test_parse_f_t_string_concat_1_error() {
|
||||||
let source = "f'Hello ' t'world'";
|
let source = "f'Hello ' t'world'";
|
||||||
let suite = parse_suite(source).unwrap();
|
let suite = parse_suite(source).unwrap_err();
|
||||||
insta::assert_debug_snapshot!(suite);
|
insta::assert_debug_snapshot!(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_f_t_string_concat_2() {
|
fn test_parse_f_t_string_concat_2_error() {
|
||||||
let source = "f'Hello ' t'world' '!'";
|
let source = "f'Hello ' t'world' '!'";
|
||||||
let suite = parse_suite(source).unwrap();
|
let suite = parse_suite(source).unwrap_err();
|
||||||
insta::assert_debug_snapshot!(suite);
|
insta::assert_debug_snapshot!(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,36 +66,34 @@ Module(
|
||||||
range: 10..19,
|
range: 10..19,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 10..19,
|
||||||
range: 10..19,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 12..18,
|
||||||
range: 12..18,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 13..14,
|
||||||
range: 13..14,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: Str,
|
||||||
conversion: Str,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,36 +20,34 @@ Module(
|
||||||
range: 44..49,
|
range: 44..49,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 44..49,
|
||||||
range: 44..49,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 46..48,
|
||||||
range: 46..48,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 47..47,
|
||||||
range: 47..47,
|
id: Name(""),
|
||||||
id: Name(""),
|
ctx: Invalid,
|
||||||
ctx: Invalid,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -66,36 +64,34 @@ Module(
|
||||||
range: 50..57,
|
range: 50..57,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 50..57,
|
||||||
range: 50..57,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 52..56,
|
||||||
range: 52..56,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 53..53,
|
||||||
range: 53..53,
|
id: Name(""),
|
||||||
id: Name(""),
|
ctx: Invalid,
|
||||||
ctx: Invalid,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,36 +20,34 @@ Module(
|
||||||
range: 44..52,
|
range: 44..52,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 44..52,
|
||||||
range: 44..52,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 46..51,
|
||||||
range: 46..51,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 47..48,
|
||||||
range: 47..48,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,36 +20,34 @@ Module(
|
||||||
range: 44..54,
|
range: 44..54,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 44..54,
|
||||||
range: 44..54,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 46..53,
|
||||||
range: 46..53,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 47..48,
|
||||||
range: 47..48,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -66,36 +64,34 @@ Module(
|
||||||
range: 55..65,
|
range: 55..65,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 55..65,
|
||||||
range: 55..65,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 57..64,
|
||||||
range: 57..64,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 58..59,
|
||||||
range: 58..59,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,43 +20,41 @@ Module(
|
||||||
range: 121..127,
|
range: 121..127,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 121..127,
|
||||||
range: 121..127,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 123..126,
|
||||||
range: 123..126,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Starred(
|
||||||
expression: Starred(
|
ExprStarred {
|
||||||
ExprStarred {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 124..125,
|
||||||
range: 124..125,
|
value: Name(
|
||||||
value: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 125..125,
|
||||||
range: 125..125,
|
id: Name(""),
|
||||||
id: Name(""),
|
ctx: Invalid,
|
||||||
ctx: Invalid,
|
},
|
||||||
},
|
),
|
||||||
),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -73,60 +71,58 @@ Module(
|
||||||
range: 128..141,
|
range: 128..141,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 128..141,
|
||||||
range: 128..141,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 130..140,
|
||||||
range: 130..140,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Starred(
|
||||||
expression: Starred(
|
ExprStarred {
|
||||||
ExprStarred {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 131..139,
|
||||||
range: 131..139,
|
value: BoolOp(
|
||||||
value: BoolOp(
|
ExprBoolOp {
|
||||||
ExprBoolOp {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 132..139,
|
||||||
range: 132..139,
|
op: And,
|
||||||
op: And,
|
values: [
|
||||||
values: [
|
Name(
|
||||||
Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 132..133,
|
||||||
range: 132..133,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
Name(
|
||||||
Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 138..139,
|
||||||
range: 138..139,
|
id: Name("y"),
|
||||||
id: Name("y"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
},
|
||||||
},
|
),
|
||||||
),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -143,51 +139,49 @@ Module(
|
||||||
range: 142..155,
|
range: 142..155,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 142..155,
|
||||||
range: 142..155,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 144..154,
|
||||||
range: 144..154,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Starred(
|
||||||
expression: Starred(
|
ExprStarred {
|
||||||
ExprStarred {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 145..153,
|
||||||
range: 145..153,
|
value: Yield(
|
||||||
value: Yield(
|
ExprYield {
|
||||||
ExprYield {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 146..153,
|
||||||
range: 146..153,
|
value: Some(
|
||||||
value: Some(
|
Name(
|
||||||
Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 152..153,
|
||||||
range: 152..153,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
},
|
),
|
||||||
),
|
},
|
||||||
ctx: Load,
|
),
|
||||||
},
|
ctx: Load,
|
||||||
),
|
},
|
||||||
debug_text: None,
|
),
|
||||||
conversion: None,
|
debug_text: None,
|
||||||
format_spec: None,
|
conversion: None,
|
||||||
},
|
format_spec: None,
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
flags: TStringFlags {
|
],
|
||||||
quote_style: Double,
|
flags: TStringFlags {
|
||||||
prefix: Regular,
|
quote_style: Double,
|
||||||
triple_quoted: false,
|
prefix: Regular,
|
||||||
},
|
triple_quoted: false,
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,78 +20,76 @@ Module(
|
||||||
range: 44..60,
|
range: 44..60,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 44..60,
|
||||||
range: 44..60,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 46..56,
|
||||||
range: 46..56,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Lambda(
|
||||||
expression: Lambda(
|
ExprLambda {
|
||||||
ExprLambda {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 47..56,
|
||||||
range: 47..56,
|
parameters: Some(
|
||||||
parameters: Some(
|
Parameters {
|
||||||
Parameters {
|
range: 54..55,
|
||||||
range: 54..55,
|
node_index: AtomicNodeIndex(
|
||||||
node_index: AtomicNodeIndex(
|
0,
|
||||||
0,
|
),
|
||||||
),
|
posonlyargs: [],
|
||||||
posonlyargs: [],
|
args: [
|
||||||
args: [
|
ParameterWithDefault {
|
||||||
ParameterWithDefault {
|
range: 54..55,
|
||||||
|
node_index: AtomicNodeIndex(..),
|
||||||
|
parameter: Parameter {
|
||||||
range: 54..55,
|
range: 54..55,
|
||||||
node_index: AtomicNodeIndex(..),
|
node_index: AtomicNodeIndex(..),
|
||||||
parameter: Parameter {
|
name: Identifier {
|
||||||
|
id: Name("x"),
|
||||||
range: 54..55,
|
range: 54..55,
|
||||||
node_index: AtomicNodeIndex(..),
|
node_index: AtomicNodeIndex(..),
|
||||||
name: Identifier {
|
|
||||||
id: Name("x"),
|
|
||||||
range: 54..55,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
},
|
|
||||||
annotation: None,
|
|
||||||
},
|
},
|
||||||
default: None,
|
annotation: None,
|
||||||
},
|
},
|
||||||
],
|
default: None,
|
||||||
vararg: None,
|
},
|
||||||
kwonlyargs: [],
|
],
|
||||||
kwarg: None,
|
vararg: None,
|
||||||
},
|
kwonlyargs: [],
|
||||||
),
|
kwarg: None,
|
||||||
body: Name(
|
},
|
||||||
ExprName {
|
),
|
||||||
node_index: AtomicNodeIndex(..),
|
body: Name(
|
||||||
range: 56..56,
|
ExprName {
|
||||||
id: Name(""),
|
node_index: AtomicNodeIndex(..),
|
||||||
ctx: Invalid,
|
range: 56..56,
|
||||||
},
|
id: Name(""),
|
||||||
),
|
ctx: Invalid,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
debug_text: None,
|
},
|
||||||
conversion: None,
|
),
|
||||||
format_spec: None,
|
debug_text: None,
|
||||||
},
|
conversion: None,
|
||||||
),
|
format_spec: None,
|
||||||
Literal(
|
},
|
||||||
InterpolatedStringLiteralElement {
|
),
|
||||||
range: 56..58,
|
Literal(
|
||||||
node_index: AtomicNodeIndex(..),
|
InterpolatedStringLiteralElement {
|
||||||
value: " x",
|
range: 56..58,
|
||||||
},
|
node_index: AtomicNodeIndex(..),
|
||||||
),
|
value: " x",
|
||||||
],
|
},
|
||||||
flags: TStringFlags {
|
),
|
||||||
quote_style: Double,
|
],
|
||||||
prefix: Regular,
|
flags: TStringFlags {
|
||||||
triple_quoted: false,
|
quote_style: Double,
|
||||||
},
|
prefix: Regular,
|
||||||
|
triple_quoted: false,
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,36 +20,34 @@ Module(
|
||||||
range: 44..48,
|
range: 44..48,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 44..48,
|
||||||
range: 44..48,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 46..47,
|
||||||
range: 46..47,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 47..47,
|
||||||
range: 47..47,
|
id: Name(""),
|
||||||
id: Name(""),
|
ctx: Invalid,
|
||||||
ctx: Invalid,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -66,36 +64,34 @@ Module(
|
||||||
range: 49..58,
|
range: 49..58,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 49..58,
|
||||||
range: 49..58,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 51..58,
|
||||||
range: 51..58,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 52..55,
|
||||||
range: 52..55,
|
id: Name("foo"),
|
||||||
id: Name("foo"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -112,41 +108,39 @@ Module(
|
||||||
range: 59..67,
|
range: 59..67,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 59..67,
|
||||||
range: 59..67,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 61..66,
|
||||||
range: 61..66,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 62..65,
|
||||||
range: 62..65,
|
id: Name("foo"),
|
||||||
id: Name("foo"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: Some(
|
||||||
debug_text: Some(
|
DebugText {
|
||||||
DebugText {
|
leading: "",
|
||||||
leading: "",
|
trailing: "=",
|
||||||
trailing: "=",
|
},
|
||||||
},
|
),
|
||||||
),
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -164,66 +158,62 @@ Module(
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Concatenated(
|
inner: Concatenated(
|
||||||
[
|
[
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 68..72,
|
||||||
range: 68..72,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 70..71,
|
||||||
range: 70..71,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 71..71,
|
||||||
range: 71..71,
|
id: Name(""),
|
||||||
id: Name(""),
|
ctx: Invalid,
|
||||||
ctx: Invalid,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 73..81,
|
||||||
range: 73..81,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 77..78,
|
||||||
range: 77..78,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 78..78,
|
||||||
range: 78..78,
|
id: Name(""),
|
||||||
id: Name(""),
|
ctx: Invalid,
|
||||||
ctx: Invalid,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: true,
|
||||||
triple_quoted: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,49 +20,47 @@ Module(
|
||||||
range: 44..56,
|
range: 44..56,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 44..56,
|
||||||
range: 44..56,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 46..52,
|
||||||
range: 46..52,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "hello ",
|
||||||
value: "hello ",
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 52..55,
|
||||||
range: 52..55,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 53..54,
|
||||||
range: 53..54,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: Some(
|
||||||
format_spec: Some(
|
InterpolatedStringFormatSpec {
|
||||||
InterpolatedStringFormatSpec {
|
range: 55..55,
|
||||||
range: 55..55,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [],
|
||||||
elements: [],
|
},
|
||||||
},
|
),
|
||||||
),
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -79,57 +77,55 @@ Module(
|
||||||
range: 57..72,
|
range: 57..72,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 57..72,
|
||||||
range: 57..72,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 59..65,
|
||||||
range: 59..65,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "hello ",
|
||||||
value: "hello ",
|
},
|
||||||
},
|
),
|
||||||
),
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 65..71,
|
||||||
range: 65..71,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 66..67,
|
||||||
range: 66..67,
|
id: Name("x"),
|
||||||
id: Name("x"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: Some(
|
||||||
format_spec: Some(
|
InterpolatedStringFormatSpec {
|
||||||
InterpolatedStringFormatSpec {
|
range: 68..71,
|
||||||
range: 68..71,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 68..71,
|
||||||
range: 68..71,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: ".3f",
|
||||||
value: ".3f",
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
},
|
||||||
},
|
),
|
||||||
),
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ input_file: crates/ruff_python_parser/resources/inline/err/template_strings_py31
|
||||||
Module(
|
Module(
|
||||||
ModModule {
|
ModModule {
|
||||||
node_index: AtomicNodeIndex(..),
|
node_index: AtomicNodeIndex(..),
|
||||||
range: 0..117,
|
range: 0..89,
|
||||||
body: [
|
body: [
|
||||||
Expr(
|
Expr(
|
||||||
StmtExpr {
|
StmtExpr {
|
||||||
|
|
@ -20,36 +20,34 @@ Module(
|
||||||
range: 44..52,
|
range: 44..52,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 44..52,
|
||||||
range: 44..52,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 46..51,
|
||||||
range: 46..51,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 47..50,
|
||||||
range: 47..50,
|
id: Name("hey"),
|
||||||
id: Name("hey"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -66,36 +64,34 @@ Module(
|
||||||
range: 53..63,
|
range: 53..63,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 53..63,
|
||||||
range: 53..63,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 55..62,
|
||||||
range: 55..62,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 56..61,
|
||||||
range: 56..61,
|
id: Name("there"),
|
||||||
id: Name("there"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Single,
|
||||||
quote_style: Single,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -112,76 +108,24 @@ Module(
|
||||||
range: 64..88,
|
range: 64..88,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 64..88,
|
||||||
range: 64..88,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 68..85,
|
||||||
range: 68..85,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "what's\nhappening?",
|
||||||
value: "what's\nhappening?",
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: true,
|
||||||
triple_quoted: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 89..116,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 89..116,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 89..101,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "implicitly",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 101..116,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 103..115,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "concatenated",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -219,13 +163,4 @@ Module(
|
||||||
4 | / t"""what's
|
4 | / t"""what's
|
||||||
5 | | happening?"""
|
5 | | happening?"""
|
||||||
| |_____________^ Syntax Error: Cannot use t-strings on Python 3.13 (syntax was added in Python 3.14)
|
| |_____________^ Syntax Error: Cannot use t-strings on Python 3.13 (syntax was added in Python 3.14)
|
||||||
6 | "implicitly"t"concatenated"
|
|
||||||
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
4 | t"""what's
|
|
||||||
5 | happening?"""
|
|
||||||
6 | "implicitly"t"concatenated"
|
|
||||||
| ^^^^^^^^^^^^^^^ Syntax Error: Cannot use t-strings on Python 3.13 (syntax was added in Python 3.14)
|
|
||||||
|
|
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -8,7 +8,7 @@ input_file: crates/ruff_python_parser/resources/inline/ok/template_strings_py314
|
||||||
Module(
|
Module(
|
||||||
ModModule {
|
ModModule {
|
||||||
node_index: AtomicNodeIndex(..),
|
node_index: AtomicNodeIndex(..),
|
||||||
range: 0..117,
|
range: 0..89,
|
||||||
body: [
|
body: [
|
||||||
Expr(
|
Expr(
|
||||||
StmtExpr {
|
StmtExpr {
|
||||||
|
|
@ -20,36 +20,34 @@ Module(
|
||||||
range: 44..52,
|
range: 44..52,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 44..52,
|
||||||
range: 44..52,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 46..51,
|
||||||
range: 46..51,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 47..50,
|
||||||
range: 47..50,
|
id: Name("hey"),
|
||||||
id: Name("hey"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -66,36 +64,34 @@ Module(
|
||||||
range: 53..63,
|
range: 53..63,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 53..63,
|
||||||
range: 53..63,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Interpolation(
|
||||||
Interpolation(
|
InterpolatedElement {
|
||||||
InterpolatedElement {
|
range: 55..62,
|
||||||
range: 55..62,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
expression: Name(
|
||||||
expression: Name(
|
ExprName {
|
||||||
ExprName {
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
range: 56..61,
|
||||||
range: 56..61,
|
id: Name("there"),
|
||||||
id: Name("there"),
|
ctx: Load,
|
||||||
ctx: Load,
|
},
|
||||||
},
|
),
|
||||||
),
|
debug_text: None,
|
||||||
debug_text: None,
|
conversion: None,
|
||||||
conversion: None,
|
format_spec: None,
|
||||||
format_spec: None,
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Single,
|
||||||
quote_style: Single,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: false,
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -112,76 +108,24 @@ Module(
|
||||||
range: 64..88,
|
range: 64..88,
|
||||||
value: TStringValue {
|
value: TStringValue {
|
||||||
inner: Single(
|
inner: Single(
|
||||||
TString(
|
TString {
|
||||||
TString {
|
range: 64..88,
|
||||||
range: 64..88,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
elements: [
|
||||||
elements: [
|
Literal(
|
||||||
Literal(
|
InterpolatedStringLiteralElement {
|
||||||
InterpolatedStringLiteralElement {
|
range: 68..85,
|
||||||
range: 68..85,
|
node_index: AtomicNodeIndex(..),
|
||||||
node_index: AtomicNodeIndex(..),
|
value: "what's\nhappening?",
|
||||||
value: "what's\nhappening?",
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
flags: TStringFlags {
|
||||||
flags: TStringFlags {
|
quote_style: Double,
|
||||||
quote_style: Double,
|
prefix: Regular,
|
||||||
prefix: Regular,
|
triple_quoted: true,
|
||||||
triple_quoted: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
),
|
},
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Expr(
|
|
||||||
StmtExpr {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 89..116,
|
|
||||||
value: TString(
|
|
||||||
ExprTString {
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
range: 89..116,
|
|
||||||
value: TStringValue {
|
|
||||||
inner: Concatenated(
|
|
||||||
[
|
|
||||||
Literal(
|
|
||||||
StringLiteral {
|
|
||||||
range: 89..101,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "implicitly",
|
|
||||||
flags: StringLiteralFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Empty,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TString(
|
|
||||||
TString {
|
|
||||||
range: 101..116,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
elements: [
|
|
||||||
Literal(
|
|
||||||
InterpolatedStringLiteralElement {
|
|
||||||
range: 103..115,
|
|
||||||
node_index: AtomicNodeIndex(..),
|
|
||||||
value: "concatenated",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
flags: TStringFlags {
|
|
||||||
quote_style: Double,
|
|
||||||
prefix: Regular,
|
|
||||||
triple_quoted: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -5424,51 +5424,25 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
|
||||||
|
|
||||||
fn infer_tstring_expression(&mut self, tstring: &ast::ExprTString) -> Type<'db> {
|
fn infer_tstring_expression(&mut self, tstring: &ast::ExprTString) -> Type<'db> {
|
||||||
let ast::ExprTString { value, .. } = tstring;
|
let ast::ExprTString { value, .. } = tstring;
|
||||||
for part in value {
|
for tstring in value {
|
||||||
match part {
|
for element in &tstring.elements {
|
||||||
ast::TStringPart::Literal(_) => {}
|
match element {
|
||||||
ast::TStringPart::FString(fstring) => {
|
ast::InterpolatedStringElement::Interpolation(
|
||||||
for element in &fstring.elements {
|
tstring_interpolation_element,
|
||||||
match element {
|
) => {
|
||||||
ast::InterpolatedStringElement::Interpolation(expression) => {
|
let ast::InterpolatedElement {
|
||||||
let ast::InterpolatedElement {
|
expression,
|
||||||
expression,
|
format_spec,
|
||||||
format_spec,
|
..
|
||||||
..
|
} = tstring_interpolation_element;
|
||||||
} = expression;
|
self.infer_expression(expression);
|
||||||
self.infer_expression(expression);
|
if let Some(format_spec) = format_spec {
|
||||||
|
for element in format_spec.elements.interpolations() {
|
||||||
if let Some(format_spec) = format_spec {
|
self.infer_expression(&element.expression);
|
||||||
for element in format_spec.elements.interpolations() {
|
|
||||||
self.infer_expression(&element.expression);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ast::InterpolatedStringElement::Literal(_) => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ast::TStringPart::TString(tstring) => {
|
|
||||||
for element in &tstring.elements {
|
|
||||||
match element {
|
|
||||||
ast::InterpolatedStringElement::Interpolation(
|
|
||||||
tstring_interpolation_element,
|
|
||||||
) => {
|
|
||||||
let ast::InterpolatedElement {
|
|
||||||
expression,
|
|
||||||
format_spec,
|
|
||||||
..
|
|
||||||
} = tstring_interpolation_element;
|
|
||||||
self.infer_expression(expression);
|
|
||||||
if let Some(format_spec) = format_spec {
|
|
||||||
for element in format_spec.elements.interpolations() {
|
|
||||||
self.infer_expression(&element.expression);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ast::InterpolatedStringElement::Literal(_) => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ast::InterpolatedStringElement::Literal(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue