ruff
Keep lambda parameters on one line and parenthesize the body if it expands
#21385
Merged

Keep lambda parameters on one line and parenthesize the body if it expands #21385

ntBre merged 103 commits into main from brent/indent-lambda-params
ntBre
ntBre ntBre added formatter
ntBre ntBre added preview
astral-sh-bot
ntBre
ntBre commented on 2025-11-11
ntBre ntBre force pushed from 6e9b2bd5 to 958f0499 350 days ago
ntBre ntBre force pushed from 93fffd1b to b65c4077 350 days ago
ntBre ntBre force pushed from b65c4077 to 68e09d51 350 days ago
ntBre ntBre force pushed from 68e09d51 to 19326a7b 350 days ago
MichaReiser
ntBre
MichaReiser
ntBre
ntBre
ntBre commented on 2025-11-12
ntBre
ntBre ntBre changed the title [WIP] Indent lambda parameters if parameters wrap [WIP] Keep lambda parameters on one line and parenthesize the body if it expands 349 days ago
ntBre ntBre changed the title [WIP] Keep lambda parameters on one line and parenthesize the body if it expands Keep lambda parameters on one line and parenthesize the body if it expands 348 days ago
ntBre
ntBre ntBre marked this pull request as ready for review 348 days ago
ntBre ntBre requested a review from MichaReiser MichaReiser 348 days ago
MichaReiser MichaReiser requested a review from amyreese amyreese 348 days ago
MichaReiser
MichaReiser commented on 2025-11-14
MichaReiser
MichaReiser commented on 2025-11-14
MichaReiser
MichaReiser
ntBre ntBre marked this pull request as draft 343 days ago
ntBre ntBre force pushed from 32d7d52d to c405b416 343 days ago
ntBre ntBre force pushed from c405b416 to 1bfcf511 342 days ago
codspeed
ntBre ntBre force pushed from 7dac1279 to b441ac64 341 days ago
ntBre ntBre changed the title Keep lambda parameters on one line and parenthesize the body if it expands Parenthesize long lambda bodies 341 days ago
ntBre ntBre force pushed from b441ac64 to c2db35b1 341 days ago
ntBre ntBre changed the title Parenthesize long lambda bodies Keep lambda parameters on one line and parenthesize the body if it expands 341 days ago
ntBre ntBre force pushed from c2db35b1 to 56c533c9 341 days ago
ntBre
MichaReiser
MichaReiser commented on 2025-11-21
ntBre
ntBre commented on 2025-11-21
ntBre ntBre force pushed from f04a18d8 to 6e7a2dce 331 days ago
ntBre
ntBre ntBre force pushed from ad77cfae to 20982524 330 days ago
amyreese
MichaReiser
MichaReiser commented on 2025-12-02
MichaReiser
MichaReiser commented on 2025-12-02
MichaReiser
MichaReiser commented on 2025-12-02
ntBre baseline test cases
1e70c991
ntBre keep lambda parameters on a single line
8cc88442
ntBre wip: parenthesize long lambda bodies
1b586430
ntBre add a poorly formatted case from the ecosystem report
74093bdb
ntBre add an unstable test case from ecosystem report
a5e13cf1
ntBre rough draft of ExprLambdaLayout::Assignment
62c968c8
ntBre add another bad case from the ecosystem check
d68a03a5
ntBre fix binary expression in lambda in return
07bcf41a
ntBre add another bad test case from the ecosystem report
6b476640
ntBre propagate lambda layout for annotated assignments
f634bb52
ntBre another bad test for long bodies with their own parens
ad314770
ntBre possibly bad test for triple-quoted f-strings
9db5d43e
ntBre exclude call and subscript expressions from has_own_parentheses
24e15bfd
ntBre avoid lambda special-casing in maybe_parenthesize_expression
0a41abed
ntBre ntBre force pushed from 40cbce56 to 7974b1c8 329 days ago
ntBre add some assignment tests with parentheses and comments
e9f9507d
ntBre add a couple more test cases
89dc1ada
ntBre ntBre force pushed from 7974b1c8 to 89dc1ada 329 days ago
ntBre
MichaReiser
MichaReiser
MichaReiser commented on 2025-12-02
MichaReiser
MichaReiser commented on 2025-12-02
MichaReiser
MichaReiser commented on 2025-12-02
ntBre use write!
18a3d593
ntBre create id only in indented case, update group name
972129c0
ntBre avoid nesting groups
2e950020
ntBre add too-eagerly parenthesized case from ecosystem
97850661
ntBre
ntBre
MichaReiser
MichaReiser commented on 2025-12-03
MichaReiser
MichaReiser
MichaReiser commented on 2025-12-03
MichaReiser
ntBre apply Micha's patch, fixing everything?
efa372b3
ntBre fix snapshot changes for cases with comments
6f6c09c7
ntBre
ntBre fix another ecosystem call expansion
9ef9d030
ntBre use parenthesize_if_expands for fluent call chains
a3400a01
ntBre add wrapping case from the ecosystem check
258b1fd7
ntBre expand parent if the lambda body breaks
04963a6b
ntBre remove comment
7dddcc85
ntBre
ntBre ntBre marked this pull request as ready for review 328 days ago
MichaReiser
MichaReiser requested changes on 2025-12-03
ntBre ntBre marked this pull request as draft 328 days ago
ntBre combine preview checks
afb01ce8
ntBre add comments and some supporting tests
2e84402f
ntBre copy mapper test case from can_omit_optional_parentheses
3a20c6f1
ntBre gate optional_parentheses branches behind stable
bdd5ba5e
ntBre Merge branch 'main' into brent/indent-lambda-params
1a3e385a
ntBre mirror comment handling from `maybe_parenthesize_expression`
08b1da3a
ntBre add some more tests
dfd3460c
MichaReiser
MichaReiser commented on 2025-12-05
ntBre check comment case first
219bbd1c
ntBre add another dangling eol case
a4b4a82e
ntBre improve dangling header comment placement
43b53edc
ntBre clippy
dc240a15
ntBre add another dangling case between lambda and parameters
5605387a
MichaReiser
MichaReiser commented on 2025-12-05
ntBre more tests
25d70b40
ntBre block indent and trailing comments
c7666423
ntBre leading_comments in block
fe255d1a
ntBre add more cases without parameters
8cbe03b3
ntBre try parenthesizing the body without parameters
c62390d1
ntBre Revert "try parenthesizing the body without parameters"
4585a0b3
ntBre factor out preview variable
3c481ba0
ntBre factor out parameters_have_comments
4d76cd7b
ntBre pairing
80852c17
ntBre wip
86406c0b
ntBre revert the last two commits, back to a stable formatting
1531c94b
ntBre fix assignment instability with dangling comments
0710e0bc
ntBre Reapply "try parenthesizing the body without parameters"
df42aa29
ntBre fix assignment instability without parameters too
f20f3e0d
ntBre move comments within lambda parameters to dangling lambda comments
8ede14a0
ntBre format new dangling comments
e8540d9b
ntBre
ntBre ntBre marked this pull request as ready for review 323 days ago
MichaReiser
MichaReiser commented on 2025-12-09
ntBre apply patch
c7b10896
ntBre clippy
ea30464a
ntBre accept snapshots
21b442a4
ntBre pass preview to handle_lambda_comment
711dd6ee
ntBre Merge branch 'main' into brent/indent-lambda-params
4ffbd496
ntBre add broken test cases
90f43bde
ntBre avoid breaking when the first parameter has leading comments
b0a82983
ntBre Merge branch 'brent/fix-kwargs' into brent/indent-lambda-params
65c94356
ntBre update snaps
fd34cd60
ntBre revert preview and comment placement changes
b8238661
ntBre revert FormatParameters changes
2bd64095
ntBre make comments leading on parameter_s_
d7221557
ntBre simplify check with parameters.start() == parameter.start()
f639389e
ntBre simplify a bit further
9d683da9
ntBre update comments
2da4798d
ntBre remove redundant parameters check
acc49ac1
ntBre update lambda comment
2e0ee2e0
ntBre Merge branch 'brent/fix-kwargs' into brent/indent-lambda-params
829f1052
ntBre clean up deref
54c76898
ntBre Merge branch 'main' into brent/indent-lambda-params
05ff8f5c
ntBre
ntBre commented on 2025-12-09
ntBre ntBre marked this pull request as draft 322 days ago
MichaReiser
MichaReiser commented on 2025-12-10
ntBre fix lambda formatting in assignments
bb053f83
ntBre factor out maybe_parenthesize_lambda
6e9e42d3
ntBre re-apply 'pass preview to handle_lambda_comment'
33fcca9c
ntBre move preview comment handling mostly into placement.rs
9f9b76b0
MichaReiser
MichaReiser commented on 2025-12-10
ntBre add preview function taking a PreviewMode
a8bebaa6
ntBre move tokenizer checks into the stable branch
f999da0e
ntBre update lambda placement docs
7c94e102
ntBre maybe_parenthesize_lambda -> maybe_parenthesize_value
8022343b
ntBre add a few more call tests with comments
b96cf96e
ntBre move dangling comment handling back out of placement.rs
553b45e2
ntBre factor out FormatBody
9d7d94c4
ntBre working for Micha's exact example
2cb98d4c
ntBre Revert leading comment changes
8711b1a3
ntBre reposition dangling comments
0f1ea90c
ntBre ntBre marked this pull request as ready for review 320 days ago
MichaReiser
MichaReiser commented on 2025-12-11
ntBre
ntBre save f.context.comments() to comments
5fee7534
ntBre share common code
d1b79f54
ntBre inline format_body
854062f8
ntBre delete outdated preview comments
6f255470
ntBre consolidate preview checks
00745159
ntBre unwrap format_body
3dfda9f6
ntBre inline current FormatBody
a48dc8ed
ntBre move all body formatting to FormatBody
b80fdfa1
ntBre
ntBre
MichaReiser
MichaReiser approved these changes on 2025-12-12
ntBre inline parameters_have_comments
4a66edf5
ntBre
ntBre share dangling comment logic
93a958a7
ntBre consolidate layout and preview checks
17a1065f
ntBre comment on leading_body_comments
d24895d4
ntBre improve dangling name and docs
3011190e
ntBre improve after_parameters_end_of_line name and docs
95301b3b
ntBre
ntBre ntBre merged 0ebdebdd into main 319 days ago
ntBre ntBre deleted the brent/indent-lambda-params branch 319 days ago

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone