ruff/crates/ruff_python_parser/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
..
lexer Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
snapshots Make Parameters an optional field on ExprLambda (#6669) 2023-08-18 15:34:54 +00:00
context.rs Remove Parse trait (#6235) 2023-08-01 18:35:03 +02:00
function.rs Implement Ranged on more structs (#6639) 2023-08-17 11:22:39 -04:00
lexer.rs Rename Magic* to IpyEscape* (#6395) 2023-08-09 13:28:18 +00:00
lib.rs Use Jupyter mode while parsing Notebook files (#5552) 2023-08-05 00:32:07 +00:00
parser.rs Expand NamedExpr range to include full range of parenthesized value (#6632) 2023-08-17 14:34:05 +00:00
python.lalrpop Make Parameters an optional field on ExprLambda (#6669) 2023-08-18 15:34:54 +00:00
python.rs Make Parameters an optional field on ExprLambda (#6669) 2023-08-18 15:34:54 +00:00
soft_keywords.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
string.rs Implement Ranged on more structs (#6639) 2023-08-17 11:22:39 -04:00
token.rs Rename Magic* to IpyEscape* (#6395) 2023-08-09 13:28:18 +00:00
typing.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00