mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 21:40:51 -05:00
Fix formatting of lambda star arguments (#6257)
## Summary Previously, the ruff formatter was removing the star argument of `lambda` expressions when formatting. Given the following code snippet ```python lambda *a: () lambda **b: () ``` it would be formatted to ```python lambda: () lambda: () ``` We fix this by checking for the presence of `args`, `vararg` or `kwarg` in the `lambda` expression, before we were only checking for the presence of `args`. Fixes #5894 ## Test Plan Add new tests cases. --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c362ea7fd4
commit
7c5791fb77
@@ -22,7 +22,8 @@ impl FormatNodeRule<ExprLambda> for FormatExprLambda {
|
||||
|
||||
write!(f, [text("lambda")])?;
|
||||
|
||||
if !parameters.args.is_empty() {
|
||||
if !parameters.args.is_empty() || parameters.vararg.is_some() || parameters.kwarg.is_some()
|
||||
{
|
||||
write!(
|
||||
f,
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user