mirror of https://github.com/astral-sh/ruff
## Summary
This PR fixes the issue to avoid collapsing the type param declaration
if
there's a comment after the opening parenthesis. For example,
```python
type foo[ # comment
A,
B
] = int
```
Here, we'll preserve the comment on the same line as is being done for
other
similar type of nodes.
## Test Plan
Add a new test case for it, update the snapshots, and validate the
ecosystem
check.
### Formatter ecosystem
#### `main`
| project | similarity index | total files | changed files |
|----------------|------------------:|------------------:|------------------:|
| cpython | 0.75803 | 1799 | 1647 |
| django | 0.99983 | 2772 | 34 |
| home-assistant | 0.99953 | 10596 | 186 |
| poetry | 0.99891 | 317 | 17 |
| transformers | 0.99966 | 2657 | 330 |
| twine | 1.00000 | 33 | 0 |
| typeshed | 0.99978 | 3669 | 20 |
| warehouse | 0.99977 | 654 | 13 |
| zulip | 0.99970 | 1459 | 22 |
#### `dhruv/type-params`
| project | similarity index | total files | changed files |
|----------------|------------------:|------------------:|------------------:|
| cpython | 0.75803 | 1799 | 1647 |
| django | 0.99983 | 2772 | 34 |
| home-assistant | 0.99953 | 10596 | 186 |
| poetry | 0.99891 | 317 | 17 |
| transformers | 0.99966 | 2657 | 330 |
| twine | 1.00000 | 33 | 0 |
| typeshed | 0.99978 | 3669 | 20 |
| warehouse | 0.99977 | 654 | 13 |
| zulip | 0.99970 | 1459 | 22 |
fixes: #8162
|
||
|---|---|---|
| .. | ||
| carriage_return | ||
| expression | ||
| fmt_on_off | ||
| fmt_skip | ||
| parentheses | ||
| statement | ||
| stub_files | ||
| .editorconfig | ||
| docstring.options.json | ||
| docstring.py | ||
| empty_multiple_trailing_newlines.py | ||
| empty_now_newline.py | ||
| empty_trailing_newline.py | ||
| empty_whitespace.py | ||
| form_feed.py | ||
| module_dangling_comment1.py | ||
| module_dangling_comment2.py | ||
| newlines.py | ||
| newlines.pyi | ||
| skip_magic_trailing_comma.options.json | ||
| skip_magic_trailing_comma.py | ||
| tab_width.options.json | ||
| tab_width.py | ||
| trailing_comments.py | ||
| trivia.py | ||