ruff/crates
Micha Reiser cb6788ab5f
Handle trailing body end-of-line comments (#4811)
### Summary

This PR adds custom logic to handle end-of-line comments of the last statement in a body. 

For example: 

```python
while True:
    if something.changed:
        do.stuff()  # trailing comment

b
```

The `# trailing comment` is a trailing comment of the `do.stuff()` expression statement. We incorrectly attached the comment as a trailing comment of the enclosing `while` statement  because the comment is between the end of the while statement (the `while` statement ends right after `do.stuff()`) and before the `b` statement. 


This PR fixes the placement to correctly attach these comments to the last statement in a body (recursively). 

## Test Plan

I reviewed the snapshots and they now look correct. This may appear odd because a lot comments have now disappeared. This is the expected result because we use `verbatim` formatting for the block statements (like `while`) and that means that it only formats the inner content of the block, but not any trailing comments. The comments were visible before, because they were associated with the block statement (e.g. `while`).
2023-06-03 15:17:33 +02:00
..
flake8_to_ruff Bump version to 0.0.270 (#4637) 2023-05-24 16:34:29 +00:00
ruff [flake8-pyi] Implement PYI035 (#4820) 2023-06-03 03:13:04 +00:00
ruff_benchmark Upgrade RustPython (#4747) 2023-05-31 08:26:35 +00:00
ruff_cache Rename ruff_python_semantic's Context struct to SemanticModel (#4565) 2023-05-22 02:35:03 +00:00
ruff_cli Replace deletion-tracking with enforced isolation levels (#4766) 2023-06-02 02:45:56 +00:00
ruff_dev Add a ruff_textwrap crate (#4731) 2023-05-31 16:35:23 +00:00
ruff_diagnostics Use a separate fix-isolation group for every parent node (#4774) 2023-06-02 03:07:55 +00:00
ruff_formatter Leading, Dangling, and Trailing comments formatting (#4785) 2023-06-02 09:26:36 +02:00
ruff_index Introduce ruff_index crate (#4597) 2023-05-23 17:40:35 +02:00
ruff_macros Merge registry into codes (#4651) 2023-06-02 10:33:01 +00:00
ruff_newlines Add a ruff_textwrap crate (#4731) 2023-05-31 16:35:23 +00:00
ruff_python_ast Add to AnyNode and AnyNodeRef conversion methods to AstNode (#4783) 2023-06-02 08:10:41 +02:00
ruff_python_formatter Handle trailing body end-of-line comments (#4811) 2023-06-03 15:17:33 +02:00
ruff_python_semantic Remove name field from import binding kinds (#4817) 2023-06-02 23:02:47 -04:00
ruff_python_stdlib Lint pyproject.toml (#4496) 2023-05-25 12:05:28 +00:00
ruff_rustpython Re-integrate RustPython parser repository (#4359) 2023-05-11 07:47:17 +00:00
ruff_testing_macros testing_macros: Add missing full feature to syn dependency (#4722) 2023-05-30 07:42:06 +00:00
ruff_textwrap Add a ruff_textwrap crate (#4731) 2023-05-31 16:35:23 +00:00
ruff_wasm Add pyflakes.extend-generics setting (#4677) 2023-06-01 22:19:37 +00:00