MCPcopy Create free account
hub / github.com/astral-sh/ruff / fmt_fields

Method fmt_fields

crates/ruff_python_formatter/src/expression/expr_f_string.rs:17–32  ·  view source on GitHub ↗
(&self, item: &ExprFString, f: &mut PyFormatter)

Source from the content-addressed store, hash-verified

15
16impl FormatNodeRule<ExprFString> for FormatExprFString {
17 fn fmt_fields(&self, item: &ExprFString, f: &mut PyFormatter) -> FormatResult<()> {
18 if let Some(f_string) = item.as_single_part_fstring() {
19 f_string.format().fmt(f)
20 } else {
21 // Always join fstrings that aren't parenthesized and thus, are always on a single line.
22 if !f.context().node_level().is_parenthesized() {
23 if let Some(format_flat) =
24 FormatImplicitConcatenatedStringFlat::new(item.into(), f.context())
25 {
26 return format_flat.fmt(f);
27 }
28 }
29
30 in_parentheses_only_group(&FormatImplicitConcatenatedString::new(item)).fmt(f)
31 }
32 }
33}
34
35impl NeedsParentheses for ExprFString {

Callers

nothing calls this directly

Calls 7

node_levelMethod · 0.80
fmtMethod · 0.45
formatMethod · 0.45
is_parenthesizedMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected