mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00: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:
parent
c362ea7fd4
commit
7c5791fb77
7 changed files with 212 additions and 242 deletions
|
@ -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,
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue