mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 11:59:10 +00:00

<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary This PR adds tests that verify that the magic trailing comma is not respected if disabled in the formatter options. Our test setup now allows to create a `<fixture-name>.options.json` file that contains an array of configurations that should be tested. <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan It's all about tests :) <!-- How was it tested? -->
80 lines
1.1 KiB
Text
80 lines
1.1 KiB
Text
---
|
|
source: crates/ruff_python_formatter/tests/fixtures.rs
|
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/trivia.py
|
|
---
|
|
## Input
|
|
```py
|
|
|
|
# Removes the line above
|
|
|
|
a = 10 # Keeps the line above
|
|
|
|
# Separated by one line from `a` and `b`
|
|
|
|
b = 20
|
|
# Adds two lines after `b`
|
|
class Test:
|
|
def a(self):
|
|
pass
|
|
# trailing comment
|
|
|
|
# two lines before, one line after
|
|
|
|
c = 30
|
|
|
|
while a == 10:
|
|
...
|
|
|
|
# trailing comment with one line before
|
|
|
|
# one line before this leading comment
|
|
|
|
d = 40
|
|
|
|
while b == 20:
|
|
...
|
|
# no empty line before
|
|
|
|
e = 50 # one empty line before
|
|
```
|
|
|
|
## Output
|
|
```py
|
|
# Removes the line above
|
|
|
|
a = 10 # Keeps the line above
|
|
|
|
# Separated by one line from `a` and `b`
|
|
|
|
b = 20
|
|
|
|
|
|
# Adds two lines after `b`
|
|
class Test:
|
|
def a(self):
|
|
pass
|
|
# trailing comment
|
|
|
|
|
|
# two lines before, one line after
|
|
|
|
c = 30
|
|
|
|
while a == 10:
|
|
...
|
|
|
|
# trailing comment with one line before
|
|
|
|
# one line before this leading comment
|
|
|
|
d = 40
|
|
|
|
while b == 20:
|
|
...
|
|
# no empty line before
|
|
|
|
e = 50 # one empty line before
|
|
```
|
|
|
|
|
|
|