ruff/crates
Charlie Marsh 474e8fbcd4
Format all attribute dot comments manually (#6825)
## Summary

This PR modifies our formatting of comments around the `.` in an
attribute. Specifically, the goal here is to avoid _reordering_
comments, and the net effect is that we generally leave comments
where-they-are when dealing with comments between around the dot (which
you can also think of as comments between attributes).

All comments around the dot are now treated as dangling and formatted
manually, with the exception of end-of-line or parenthesized comments on
the value, like those marked as trailing here, which remain trailing:

```python
(
    (
        a # trailing end-of-line
        # trailing own-line
    ) # dangling before dot end-of-line
    .b # trailing end-of-line
)
```

Closes https://github.com/astral-sh/ruff/issues/6823.

## Test Plan

`cargo test`

Before:

| project      | similarity index |
|--------------|------------------|
| cpython      | 0.76050          |
| django       | 0.99820          |
| transformers | 0.99800          |
| twine        | 0.99876          |
| typeshed     | 0.99953          |
| warehouse    | 0.99615          |
| zulip        | 0.99729          |

After:

| project      | similarity index |
|--------------|------------------|
| cpython      | 0.76050          |
| django       | 0.99820   |
| transformers | 0.99800          |
| twine        | 0.99876          |
| typeshed     | 0.99953          |
| warehouse    | 0.99615          |
| zulip        | 0.99729          |
2023-08-25 03:50:56 +00:00
..
flake8_to_ruff Bump version to 0.0.285 (#6660) 2023-08-17 15:46:28 -05:00
ruff Make isort's detect-same-package behavior configurable (#6833) 2023-08-24 14:09:26 -04:00
ruff_benchmark Extend BestFitting with mode (#6814) 2023-08-23 17:23:45 +02:00
ruff_cache Error on zero tab width (#6429) 2023-08-08 16:51:37 -04:00
ruff_cli Remove some indexing (#6728) 2023-08-21 16:56:15 +02:00
ruff_dev Improve formatter contributor docs (#6776) 2023-08-24 10:45:08 +00:00
ruff_diagnostics Avoid attempting to fix PT018 in multi-statement lines (#6829) 2023-08-23 19:09:34 -04:00
ruff_formatter Printer: Slice based queue and stack (#6819) 2023-08-24 14:49:27 +02:00
ruff_index Add unreachable code rule (#5384) 2023-07-04 14:27:23 +00:00
ruff_macros Remove parser dependency from ruff-python-ast (#6096) 2023-07-26 17:47:22 +02:00
ruff_python_ast Avoid attempting to fix PT018 in multi-statement lines (#6829) 2023-08-23 19:09:34 -04:00
ruff_python_codegen Make Parameters an optional field on ExprLambda (#6669) 2023-08-18 15:34:54 +00:00
ruff_python_formatter Format all attribute dot comments manually (#6825) 2023-08-25 03:50:56 +00:00
ruff_python_index Avoid attempting to fix PT018 in multi-statement lines (#6829) 2023-08-23 19:09:34 -04:00
ruff_python_literal Add support for nested replacements inside format specifications (#6616) 2023-08-17 09:07:30 -05:00
ruff_python_parser Remove lexing for colon-matching use cases (#6803) 2023-08-23 04:44:51 +00:00
ruff_python_resolver Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
ruff_python_semantic Update mutable-argument-default (B006) to use extend-immutable-calls when determining if annotations are immutable (#6781) 2023-08-23 15:44:35 +00:00
ruff_python_stdlib Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
ruff_python_trivia Format all attribute dot comments manually (#6825) 2023-08-25 03:50:56 +00:00
ruff_shrinking Implement Ranged on more structs (#6639) 2023-08-17 11:22:39 -04:00
ruff_source_file Skip BOM when determining Locator's line starts (#6159) 2023-07-29 11:47:13 +00:00
ruff_text_size Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_wasm Set a default on PythonVersion (#6446) 2023-08-09 15:19:27 +00:00