mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 17:41:12 +00:00
Formatter: Remove unnecessary group
(#8455)
This commit is contained in:
parent
d04d964ace
commit
f16505d885
2 changed files with 1 additions and 24 deletions
|
@ -2516,33 +2516,10 @@ impl Parameters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::borrowed_box)] // local utility
|
|
||||||
fn clone_boxed_expr(expr: &Box<Expr>) -> Box<Expr> {
|
|
||||||
let expr: &Expr = expr.as_ref();
|
|
||||||
Box::new(expr.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ParameterWithDefault {
|
impl ParameterWithDefault {
|
||||||
pub fn as_parameter(&self) -> &Parameter {
|
pub fn as_parameter(&self) -> &Parameter {
|
||||||
&self.parameter
|
&self.parameter
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_parameter(&self) -> (Parameter, Option<Box<Expr>>) {
|
|
||||||
let ParameterWithDefault {
|
|
||||||
range: _,
|
|
||||||
parameter,
|
|
||||||
default,
|
|
||||||
} = self;
|
|
||||||
(parameter.clone(), default.as_ref().map(clone_boxed_expr))
|
|
||||||
}
|
|
||||||
pub fn into_parameter(self) -> (Parameter, Option<Box<Expr>>) {
|
|
||||||
let ParameterWithDefault {
|
|
||||||
range: _,
|
|
||||||
parameter,
|
|
||||||
default,
|
|
||||||
} = self;
|
|
||||||
(parameter, default)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parameters {
|
impl Parameters {
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl FormatNodeRule<ParameterWithDefault> for FormatParameterWithDefault {
|
||||||
token("="),
|
token("="),
|
||||||
(!needs_line_break).then_some(space),
|
(!needs_line_break).then_some(space),
|
||||||
needs_line_break.then_some(hard_line_break()),
|
needs_line_break.then_some(hard_line_break()),
|
||||||
group(&default.format())
|
default.format()
|
||||||
]
|
]
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue