ruff/crates
konsti 3a2c3a7398
Format empty lines in stub files like black's preview style (#7206)
## Summary

Fix all but one empty line differences with the black preview style in
typeshed. The remaining differences are breaking with type comments and
trailing commas in function definitions.

I compared the empty line differences with the preview mode of black
since stable has some oddities that would have been hard to replicate
(https://github.com/psf/black/issues/3861). Additionally, it assumes the
style proposed in https://github.com/psf/black/issues/3862.

An edge case that also surfaced with typeshed are newline before
trailing module comments.

**main**

| project | similarity index | total files | changed files |

|--------------|------------------:|------------------:|------------------:|
| cpython | 0.76083 | 1789 | 1632 |
| django | 0.99966 | 2760 | 58 |
| transformers | 0.99930 | 2587 | 447 |
| twine | 1.00000 | 33 | 0 |
| **typeshed** | 0.99978 | 3496 | **2173** |
| warehouse | 0.99825 | 648 | 22 |
| zulip | 0.99950 | 1437 | 27 |

**PR**
| project | similarity index | total files | changed files |

|--------------|------------------:|------------------:|------------------:|
| cpython | 0.76083 | 1789 | 1632 |
| django | 0.99966 | 2760 | 58 |
| transformers | 0.99930 | 2587 | 447 |
| twine | 1.00000 | 33 | 0 |
| **typeshed** | 0.99983 | 3496 | **18** |
| warehouse | 0.99825 | 648 | 22 |
| zulip | 0.99950 | 1437 | 27 |


Closes #6723

## Test Plan

The main driver was the typeshed diff. I added new test cases for all
kinds of possible empty line combinations in stub files, test cases for
newlines before trailing module comments.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2023-09-11 08:03:59 +00:00
..
flake8_to_ruff Bump version to 0.0.287 (#7038) 2023-09-01 17:32:26 +01:00
ruff Avoid F401 panic with noqa import name (#7260) 2023-09-10 16:31:25 +00:00
ruff_benchmark Remove IO based lints from linter benchmark (#7240) 2023-09-08 13:39:50 +02:00
ruff_cache Error on zero tab width (#6429) 2023-08-08 16:51:37 -04:00
ruff_cli Add PreviewMode option to formatter 2023-09-08 12:04:28 +02:00
ruff_dev Use ruff line-length in format_dev (#6870) 2023-09-05 16:19:17 +02:00
ruff_diagnostics Create `ruff_notebook` crate (#7039) 2023-09-01 13:56:44 +00:00
ruff_formatter Split implicit concatenated strings before binary expressions (#7145) 2023-09-08 06:51:26 +00:00
ruff_index Add unreachable code rule (#5384) 2023-07-04 14:27:23 +00:00
ruff_macros Move `Configuration` to `ruff_workspace` crate (#6920) 2023-08-28 06:21:35 +00:00
ruff_notebook Create `ruff_notebook` crate (#7039) 2023-09-01 13:56:44 +00:00
ruff_python_ast Move `ExprConstant::kind` to `StringConstant::unicode` (#7180) 2023-09-06 07:39:25 +00:00
ruff_python_codegen Move `ExprConstant::kind` to `StringConstant::unicode` (#7180) 2023-09-06 07:39:25 +00:00
ruff_python_formatter Format empty lines in stub files like black's preview style (#7206) 2023-09-11 08:03:59 +00:00
ruff_python_index Move `Ranged` into `ruff_text_size` (#6919) 2023-08-27 14:12:51 -04:00
ruff_python_literal Avoid parsing other parts of a format specification if replacements are present (#6858) 2023-08-25 17:42:57 +00:00
ruff_python_parser Avoid allocating in lex_decimal (#7252) 2023-09-11 06:37:25 +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 Move `refurb/helpers` utils to `ruff_python_semantic` for broader use (#6990) 2023-08-29 14:45:09 -04:00
ruff_python_stdlib Use the unicode-ident crate (#7212) 2023-09-07 08:19:25 +00:00
ruff_python_trivia Use the unicode-ident crate (#7212) 2023-09-07 08:19:25 +00:00
ruff_shrinking Move `Ranged` into `ruff_text_size` (#6919) 2023-08-27 14:12:51 -04:00
ruff_source_file Fixed panic in `missing_copyright_notice` (#7029) 2023-09-01 13:58:48 +00:00
ruff_text_size Unify line size settings between ruff and the formatter (#6873) 2023-08-28 06:44:56 +00:00
ruff_wasm Split implicit concatenated strings before binary expressions (#7145) 2023-09-08 06:51:26 +00:00
ruff_workspace Add `extend-ignore-names` for `flake8-self` (#7194) 2023-09-07 13:41:22 +00:00