Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Fix empty lambda args range #35

Merged
merged 2 commits into from
Jul 21, 2023
Merged

Fix empty lambda args range #35

merged 2 commits into from
Jul 21, 2023

Conversation

konstin
Copy link
Member

@konstin konstin commented Jul 21, 2023

Previously, empty lambda arguments (e.g. lambda: 1) would get the range of the entire expression, which leads to incorrect comment placement. Now empty lambda arguments get an empty range between the lambda and the : tokens.

Previously, empty lambda arguments would get the range of the entire expression, which would lead to incorrect comment placement. Now empty lambda arguments also have an empty range between the `lambda` and the `:` tokens.
@konstin konstin requested a review from MichaReiser July 21, 2023 09:52
konstin added a commit to astral-sh/ruff that referenced this pull request Jul 21, 2023
**Summary** Fix implemented in astral-sh/RustPython-Parser#35: Previously, empty lambda arguments (e.g. `lambda: 1`) would get the range of the entire expression, which leads to incorrect comment placement. Now empty lambda arguments get an empty range between the `lambda` and the `:` tokens.

**Test Plan** Added a regression test.

149 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
149
```
konstin added a commit to astral-sh/ruff that referenced this pull request Jul 21, 2023
**Summary** Fix implemented in astral-sh/RustPython-Parser#35: Previously, empty lambda arguments (e.g. `lambda: 1`) would get the range of the entire expression, which leads to incorrect comment placement. Now empty lambda arguments get an empty range between the `lambda` and the `:` tokens.

**Test Plan** Added a regression test.

149 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
149
```
konstin added a commit to astral-sh/ruff that referenced this pull request Jul 21, 2023
**Summary** Fix implemented in
astral-sh/RustPython-Parser#35: Previously,
empty lambda arguments (e.g. `lambda: 1`) would get the range of the
entire expression, which leads to incorrect comment placement. Now empty
lambda arguments get an empty range between the `lambda` and the `:`
tokens.

**Test Plan** Added a regression test.

149 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
149
```
@konstin konstin merged commit 4d03b9b into main Jul 21, 2023
3 checks passed
@konstin konstin deleted the fix_empty_lambda_args_range branch July 21, 2023 15:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants