konsti
46f8961292
Formatter: Add EmptyWithDanglingComments helper ( #5951 )
...
**Summary** Add a `EmptyWithDanglingComments` format helper that formats
comments inside empty parentheses, brackets or curly braces. Previously,
this was implemented separately, and partially incorrectly, for each use
case.
Empty `()`, `[]` and `{}` are special because there can be dangling
comments, and they can be in
two positions:
```python
x = [ # end-of-line
# own line
]
```
These comments are dangling because they can't be assigned to any
element inside as they would
in all other cases.
**Test Plan** Added a regression test.
145 (from previously 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
145
```
2023-07-23 14:32:16 +02:00
..
2023-07-19 13:01:58 +02:00
2023-06-30 06:32:50 +00:00
2023-07-21 12:07:51 +00:00
2023-07-11 06:08:08 +00:00
2023-06-30 06:32:50 +00:00
2023-07-13 09:27:25 +00:00
2023-07-11 16:40:28 +02:00
2023-07-21 12:07:51 +00:00
2023-06-30 06:32:50 +00:00
2023-07-13 09:27:25 +00:00
2023-06-30 06:32:50 +00:00
2023-06-30 06:32:50 +00:00
2023-07-19 11:47:56 +00:00
2023-07-19 11:47:56 +00:00
2023-07-15 15:50:47 +01:00
2023-07-10 12:32:15 +00:00
2023-06-30 06:32:50 +00:00
2023-07-11 16:40:28 +02:00
2023-07-19 13:01:58 +02:00
2023-06-30 06:32:50 +00:00
2023-07-03 21:48:44 +02:00
2023-07-19 13:01:58 +02:00
2023-06-30 06:32:50 +00:00
2023-07-19 17:28:07 +02:00
2023-07-19 17:28:07 +02:00
2023-06-30 06:32:50 +00:00
2023-06-30 06:32:50 +00:00
2023-06-30 06:32:50 +00:00
2023-07-19 17:28:07 +02:00
2023-07-13 08:57:29 +02:00
2023-07-11 06:08:08 +00:00
2023-06-30 06:32:50 +00:00
2023-07-04 07:07:20 +00:00
2023-07-14 09:01:33 +02:00
2023-07-14 09:01:33 +02:00
2023-07-13 09:27:25 +00:00
2023-06-30 06:32:50 +00:00
2023-07-14 09:01:33 +02:00
2023-07-21 12:07:51 +00:00
2023-07-14 09:01:33 +02:00
2023-06-30 06:32:50 +00:00
2023-07-03 21:48:44 +02:00
2023-07-13 08:57:29 +02:00
2023-07-21 12:07:51 +00:00
2023-06-30 06:32:50 +00:00
2023-06-30 06:32:50 +00:00
2023-07-11 16:51:24 +02:00
2023-06-30 06:32:50 +00:00
2023-07-17 10:38:59 +02:00
2023-06-30 06:32:50 +00:00
2023-07-13 09:27:25 +00:00
2023-07-04 07:07:20 +00:00
2023-07-21 12:07:51 +00:00
2023-07-19 17:28:07 +02:00
2023-07-04 07:07:20 +00:00
2023-07-19 17:28:07 +02:00
2023-07-19 11:47:56 +00:00
2023-07-21 12:07:51 +00:00
2023-07-10 21:23:49 +02:00
2023-07-19 11:47:56 +00:00
2023-07-13 09:27:25 +00:00
2023-07-15 17:35:23 +01:00
2023-07-11 16:40:28 +02:00
2023-07-13 09:27:25 +00:00
2023-07-14 09:01:33 +02:00
2023-07-11 14:07:39 +02:00
2023-07-14 09:01:33 +02:00
2023-06-30 06:32:50 +00:00
2023-06-30 06:32:50 +00:00
2023-06-30 10:13:23 +02:00
2023-07-11 16:40:28 +02:00
2023-07-04 07:07:20 +00:00
2023-07-20 10:07:22 +00:00
2023-06-27 09:29:40 +00:00
2023-07-11 16:51:24 +02:00
2023-07-14 17:54:58 +02:00
2023-07-20 10:07:22 +00:00
2023-07-23 14:32:16 +02:00
2023-07-19 13:01:58 +02:00
2023-07-10 15:55:19 +02:00
2023-07-21 15:48:45 +02:00
2023-07-20 10:07:22 +00:00
2023-07-03 21:48:44 +02:00
2023-07-10 12:32:15 +00:00
2023-07-20 10:07:22 +00:00
2023-07-20 15:05:18 +00:00
2023-07-11 06:08:08 +00:00
2023-07-14 17:54:58 +02:00
2023-07-10 21:23:49 +02:00
2023-07-11 14:07:39 +02:00
2023-07-21 12:07:51 +00:00
2023-07-21 12:07:51 +00:00
2023-07-08 12:33:18 +02:00
2023-07-13 10:51:25 +00:00
2023-07-14 09:01:33 +02:00
2023-07-13 16:00:49 +02:00
2023-07-13 10:51:25 +00:00
2023-06-26 14:15:55 +02:00
2023-06-29 08:09:26 +02:00
2023-07-23 14:32:16 +02:00
2023-07-13 08:57:29 +02:00
2023-07-18 13:40:15 +02:00
2023-07-18 13:40:15 +02:00
2023-07-04 07:07:20 +00:00
2023-07-04 07:07:20 +00:00
2023-07-13 08:57:29 +02:00
2023-07-06 18:23:53 +00:00
2023-07-19 17:28:07 +02:00
2023-07-13 08:57:29 +02:00
2023-07-19 13:01:58 +02:00
2023-06-26 14:15:55 +02:00