mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-12 21:36:47 +00:00
add DebugText
for self-documenting f-strings (#6167)
This commit is contained in:
parent
44a8d1c644
commit
ba990b676f
26 changed files with 148 additions and 155 deletions
|
@ -888,6 +888,7 @@ impl From<ExprCall> for Expr {
|
|||
pub struct ExprFormattedValue {
|
||||
pub range: TextRange,
|
||||
pub value: Box<Expr>,
|
||||
pub debug_text: Option<DebugText>,
|
||||
pub conversion: ConversionFlag,
|
||||
pub format_spec: Option<Box<Expr>>,
|
||||
}
|
||||
|
@ -925,6 +926,14 @@ impl ConversionFlag {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct DebugText {
|
||||
/// The text between the `{` and the expression node.
|
||||
pub leading: String,
|
||||
/// The text between the expression and the conversion, the format_spec, or the `}`, depending on what's present in the source
|
||||
pub trailing: String,
|
||||
}
|
||||
|
||||
/// See also [JoinedStr](https://docs.python.org/3/library/ast.html#ast.JoinedStr)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ExprJoinedStr {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue