mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Don't format trailing comma for lambda arguments (#5946)
**Summary** lambda arguments don't have parentheses, so they shouldn't get a magic trailing comma either. This fixes some unstable formatting **Test Plan** Added a regression test. 89 (from previously 145) instances of unstable formatting remaining. ``` $ cargo run --bin ruff_dev --release -- format-dev --stability-check --error-file formatter-ecosystem-errors.txt --multi-project target/checkouts > formatter-ecosystem-progress.txt $ rg "Unstable formatting" target/formatter-ecosystem-errors.txt | wc -l 89 ``` Closes #5892
This commit is contained in:
parent
40f54375cb
commit
06d9ff9577
5 changed files with 126 additions and 28 deletions
|
@ -66,3 +66,12 @@ a = (
|
|||
# formatting
|
||||
(lambda:(#
|
||||
),)
|
||||
|
||||
# lambda arguments don't have parentheses, so we never add a magic trailing comma ...
|
||||
def f(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = lambda x: y,
|
||||
):
|
||||
pass
|
||||
|
||||
# ...but we do preserve a trailing comma after the arguments
|
||||
a = lambda b,: 0
|
||||
|
|
|
@ -20,3 +20,10 @@
|
|||
"seventh entry",
|
||||
"eighth entry",
|
||||
)
|
||||
|
||||
# Regression test: Respect setting in Arguments formatting
|
||||
def f(a): pass
|
||||
def g(a,): pass
|
||||
|
||||
x1 = lambda y: 1
|
||||
x2 = lambda y,: 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue