-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
no_blank_line_before_class_docstring
preview style (#9154)
## Summary This PR implements the `no_blank_line_before_class_docstring` preview style. ## Test Plan Update existing snapshots. ### Formatter ecosystem `main` | project | similarity index | total files | changed files | |----------------|------------------:|------------------:|------------------:| | cpython | 0.75804 | 1799 | 1648 | | django | 0.99984 | 2772 | 34 | | home-assistant | 0.99955 | 10596 | 213 | | poetry | 0.99905 | 321 | 15 | | transformers | 0.99967 | 2657 | 324 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99980 | 3669 | 18 | | warehouse | 0.99976 | 654 | 14 | | zulip | 0.99958 | 1459 | 36 | `dhruv/no-blank-line-docstring` | project | similarity index | total files | changed files | |----------------|------------------:|------------------:|------------------:| | cpython | 0.75804 | 1799 | 1648 | | django | 0.99984 | 2772 | 34 | | home-assistant | 0.99955 | 10596 | 213 | | poetry | 0.99905 | 321 | 15 | | transformers | 0.99967 | 2657 | 324 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99980 | 3669 | 18 | | warehouse | 0.99976 | 654 | 14 | | zulip | 0.99958 | 1459 | 36 | fixes: #8888
- Loading branch information
1 parent
7c89492
commit 09296e3
Showing
9 changed files
with
184 additions
and
148 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...hon_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
{ | ||
"preview": "enabled" | ||
} | ||
] |
38 changes: 38 additions & 0 deletions
38
...s/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class NormalDocstring: | ||
|
||
"""This is a docstring.""" | ||
|
||
|
||
class DocstringWithComment0: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
|
||
|
||
class DocstringWithComment1: | ||
# This is a comment | ||
|
||
"""This is a docstring.""" | ||
|
||
|
||
class DocstringWithComment2: | ||
|
||
# This is a comment | ||
"""This is a docstring.""" | ||
|
||
|
||
class DocstringWithComment3: | ||
|
||
# This is a comment | ||
|
||
"""This is a docstring.""" | ||
|
||
|
||
class DocstringWithComment4: | ||
|
||
|
||
# This is a comment | ||
|
||
|
||
"""This is a docstring.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 0 additions & 134 deletions
134
...tests/snapshots/black_compatibility@cases__preview_no_blank_line_before_docstring.py.snap
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...es/ruff_python_formatter/tests/snapshots/format@blank_line_before_class_docstring.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
source: crates/ruff_python_formatter/tests/fixtures.rs | ||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.py | ||
--- | ||
## Input | ||
```python | ||
class NormalDocstring: | ||
"""This is a docstring.""" | ||
class DocstringWithComment0: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
class DocstringWithComment1: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
class DocstringWithComment2: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
class DocstringWithComment3: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
class DocstringWithComment4: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
``` | ||
|
||
## Outputs | ||
### Output 1 | ||
``` | ||
indent-style = space | ||
line-width = 88 | ||
indent-width = 4 | ||
quote-style = Double | ||
line-ending = LineFeed | ||
magic-trailing-comma = Respect | ||
docstring-code = Disabled | ||
docstring-code-line-width = "dynamic" | ||
preview = Enabled | ||
``` | ||
|
||
```python | ||
class NormalDocstring: | ||
"""This is a docstring.""" | ||
class DocstringWithComment0: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
class DocstringWithComment1: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
class DocstringWithComment2: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
class DocstringWithComment3: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
class DocstringWithComment4: | ||
# This is a comment | ||
"""This is a docstring.""" | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.