ruff/crates/ruff_python_formatter/src
Charlie Marsh 6a5acde226
Make Parameters an optional field on ExprLambda (#6669)
## Summary

If a lambda doesn't contain any parameters, or any parameter _tokens_
(like `*`), we can use `None` for the parameters. This feels like a
better representation to me, since, e.g., what should the `TextRange` be
for a non-existent set of parameters? It also allows us to remove
several sites where we check if the `Parameters` is empty by seeing if
it contains any arguments, so semantically, we're already trying to
detect and model around this elsewhere.

Changing this also fixes a number of issues with dangling comments in
parameter-less lambdas, since those comments are now automatically
marked as dangling on the lambda. (As-is, we were also doing something
not-great whereby the lambda was responsible for formatting dangling
comments on the parameters, which has been removed.)

Closes https://github.com/astral-sh/ruff/issues/6646.

Closes https://github.com/astral-sh/ruff/issues/6647.

## Test Plan

`cargo test`
2023-08-18 15:34:54 +00:00
..
comments Make Parameters an optional field on ExprLambda (#6669) 2023-08-18 15:34:54 +00:00
expression Make Parameters an optional field on ExprLambda (#6669) 2023-08-18 15:34:54 +00:00
module Add empty lines before nested functions and classes (#6206) 2023-08-01 15:30:59 +00:00
other Make Parameters an optional field on ExprLambda (#6669) 2023-08-18 15:34:54 +00:00
pattern Call pattern formatting (#6594) 2023-08-16 08:31:25 +05:30
snapshots Remove exception-handler lexing from unused-bound-exception fix (#5851) 2023-07-18 18:27:46 +00:00
statement Rename Comments methods (#6649) 2023-08-18 06:37:01 +00:00
type_param Rename Comments methods (#6649) 2023-08-18 06:37:01 +00:00
builders.rs Improve with statement comment handling and expression breaking (#6621) 2023-08-18 03:30:38 +00:00
cli.rs Formatter: Add SourceType to context to enable special formatting for stub files (#6331) 2023-08-04 11:52:26 +00:00
context.rs Implement DerefMut for WithNodeLevel (#6443) 2023-08-11 10:41:48 +00:00
generated.rs Remove Stmt::TryStar (#6566) 2023-08-14 13:39:44 -04:00
lib.rs Rename Comments methods (#6649) 2023-08-18 06:37:01 +00:00
main.rs Formatter: Add SourceType to context to enable special formatting for stub files (#6331) 2023-08-04 11:52:26 +00:00
options.rs Improve with statement comment handling and expression breaking (#6621) 2023-08-18 03:30:38 +00:00
prelude.rs Accept any Into<AnyNodeRef> as Comments arguments (#5205) 2023-06-20 16:49:21 +00:00
verbatim.rs Rename Comments methods (#6649) 2023-08-18 06:37:01 +00:00