ruff/crates
konstin 6155fd647d
Format Slice Expressions (#5047)
This formats slice expressions and subscript expressions.

Spaces around the colons follows the same rules as black
(https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#slices):
```python
e00 = "e"[:]
e01 = "e"[:1]
e02 = "e"[: a()]
e10 = "e"[1:]
e11 = "e"[1:1]
e12 = "e"[1 : a()]
e20 = "e"[a() :]
e21 = "e"[a() : 1]
e22 = "e"[a() : a()]
e200 = "e"[a() : :]
e201 = "e"[a() :: 1]
e202 = "e"[a() :: a()]
e210 = "e"[a() : 1 :]
```

Comment placement is different due to our very different infrastructure.
If we have explicit bounds (e.g. `x[1:2]`) all comments get assigned as
leading or trailing to the bound expression. If a bound is missing
`[:]`, comments get marked as dangling and placed in the same section as
they were originally in:
```python
x = "x"[ # a
      # b
    :  # c
      # d
]
```
to
```python
x = "x"[
    # a
    # b
    :
    # c
    # d
]
```
Except for the potential trailing end-of-line comments, all comments get
formatted on their own line. This can be improved by keeping end-of-line
comments after the opening bracket or after a colon as such but the
changes were already complex enough.

I added tests for comment placement and spaces.
2023-06-21 15:09:39 +00:00
..
flake8_to_ruff Bump version to 0.0.274 (#5230) 2023-06-20 22:12:32 -04:00
ruff Add support for top-level quoted annotations in RUF013 (#5235) 2023-06-21 10:23:37 -04:00
ruff_benchmark Unify benchmarking and profiling docs (#5145) 2023-06-21 09:39:56 +00:00
ruff_cache Only use a single cache file per Python package (#5117) 2023-06-19 17:46:13 +02:00
ruff_cli Bump version to 0.0.274 (#5230) 2023-06-20 22:12:32 -04:00
ruff_dev Add a script that tests formatter stability on repositories (#5055) 2023-06-19 14:13:38 +00:00
ruff_diagnostics Use consistent Cargo.toml metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_formatter Add BestFittingMode (#5184) 2023-06-20 18:16:01 +02:00
ruff_index Run rustfmt on nightly to clean up erroneous comments (#5106) 2023-06-15 00:19:05 +00:00
ruff_macros Refactor top llvm-lines entry (#5147) 2023-06-18 12:39:06 +02:00
ruff_python_ast Fix ArgWithDefault comments handling (#5204) 2023-06-20 20:48:07 +00:00
ruff_python_formatter Format Slice Expressions (#5047) 2023-06-21 15:09:39 +00:00
ruff_python_semantic Move StarImport to its own module (#5186) 2023-06-20 13:12:46 -04:00
ruff_python_stdlib Replace static CallPath vectors with matches! macros (#5148) 2023-06-16 17:34:42 +00:00
ruff_python_whitespace Use consistent Cargo.toml metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_rustpython Use consistent Cargo.toml metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_testing_macros Use consistent Cargo.toml metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_textwrap Use consistent Cargo.toml metadata in all crates (#5015) 2023-06-12 00:02:40 +00:00
ruff_wasm Move copyright rules to flake8_copyright module (#5236) 2023-06-21 01:56:40 +00:00