ruff/crates/ruff_python_formatter/src/comments
Charlie Marsh 7f1456a2c9
Allow up to two newlines before trailing clause body comments (#7575)
## Summary

This is the peer to https://github.com/astral-sh/ruff/pull/7557, but for
"leading" clause comments, like:

```python
if True:
    pass


# comment
else:
    pass
```

In this case, we again want to allow up to two newlines at the top
level.

## Test Plan

`cargo test`

No changes.

Before:

| project | similarity index | total files | changed files |

|--------------|------------------:|------------------:|------------------:|
| cpython | 0.76083 | 1789 | 1631 |
| django | 0.99983 | 2760 | 36 |
| transformers | 0.99963 | 2587 | 323 |
| twine | 1.00000 | 33 | 0 |
| typeshed | 0.99979 | 3496 | 22 |
| warehouse | 0.99967 | 648 | 15 |
| zulip | 0.99972 | 1437 | 21 |

After:

| project | similarity index | total files | changed files |

|--------------|------------------:|------------------:|------------------:|
| cpython | 0.76083 | 1789 | 1631 |
| django | 0.99983 | 2760 | 36 |
| transformers | 0.99963 | 2587 | 323 |
| twine | 1.00000 | 33 | 0 |
| typeshed | 0.99979 | 3496 | 22 |
| warehouse | 0.99967 | 648 | 15 |
| zulip | 0.99972 | 1437 | 21 |
2023-09-21 14:52:38 +00:00
..
snapshots Fix dangling module comments (#7456) 2023-09-17 14:56:41 +00:00
debug.rs Use CommentRanges in backwards lexing (#7360) 2023-09-16 03:21:45 +00:00
format.rs Allow up to two newlines before trailing clause body comments (#7575) 2023-09-21 14:52:38 +00:00
map.rs Use single lookup for leading, dangling, and trailing comments (#6589) 2023-08-15 17:39:45 +02:00
mod.rs Fix build (#7437) 2023-09-16 14:50:36 +00:00
node_key.rs Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
placement.rs Add dangling comment handling for lambda expressions (#7493) 2023-09-19 15:23:51 -04:00
visitor.rs Use CommentRanges in backwards lexing (#7360) 2023-09-16 03:21:45 +00:00