Fix leading comment formatting for lambdas with multiple parameters by ntBre · Pull Request #21879 · astral-sh/ruff (original) (raw)

added 2 commits

December 9, 2025 15:06

@ntBre

the new leading comment is causing the whole Parameters list to break. these cases should instead format like:

(
    lambda
    # comment
    *x, **y: x
)

(
    lambda
    # comment 2
    *x, **y: x
)

without line breaks in the parameter list

@ntBre

@ntBre

@ntBre

@ntBre

and fix some names

the start check handles both the are_parameters_parenthesized check (because lambda parameters cannot be parenthesized and thus nothing can come between the start of the parameters and the first parameter) and the comparison with first.range() since the parameters start where the first parameter starts

@ntBre

@ntBre

@ntBre

I believe parameters itself would be None if there were no next parameter

@ntBre

MichaReiser

@ntBre ntBre marked this pull request as ready for review

December 9, 2025 22:30

@ntBre ntBre deleted the brent/fix-kwargs branch

December 9, 2025 23:15

dcreager added a commit that referenced this pull request

Dec 10, 2025

@dcreager

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})