-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
# fmt: skip
with interspersed same-line comments (#9395)
## Summary This is similar to #8876, but more limited in scope: 1. It only applies to `# fmt: skip` (like Black). Like `# isort: on`, `# fmt: on` needs to be on its own line (still). 2. It only delimits on `#`, so you can do `# fmt: skip # noqa`, but not `# fmt: skip - some other content` or `# fmt: skip; noqa`. If we want to support the `;`-delimited version, we should revisit later, since we don't support that in the linter (so `# fmt: skip; noqa` wouldn't register a `noqa`). Closes #8892.
- Loading branch information
1 parent
4b8b3a1
commit 60ba7a7
Showing
4 changed files
with
66 additions
and
13 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/reason.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,9 @@ | ||
# Supported | ||
x = 1 # fmt: skip | ||
x = 1 # fmt: skip # reason | ||
x = 1 # reason # fmt: skip | ||
|
||
# Unsupported | ||
x = 1 # fmt: skip reason | ||
x = 1 # fmt: skip - reason | ||
x = 1 # fmt: skip; noqa |
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
32 changes: 32 additions & 0 deletions
32
crates/ruff_python_formatter/tests/snapshots/format@fmt_skip__reason.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,32 @@ | ||
--- | ||
source: crates/ruff_python_formatter/tests/fixtures.rs | ||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/reason.py | ||
--- | ||
## Input | ||
```python | ||
# Supported | ||
x = 1 # fmt: skip | ||
x = 1 # fmt: skip # reason | ||
x = 1 # reason # fmt: skip | ||
# Unsupported | ||
x = 1 # fmt: skip reason | ||
x = 1 # fmt: skip - reason | ||
x = 1 # fmt: skip; noqa | ||
``` | ||
|
||
## Output | ||
```python | ||
# Supported | ||
x = 1 # fmt: skip | ||
x = 1 # fmt: skip # reason | ||
x = 1 # reason # fmt: skip | ||
# Unsupported | ||
x = 1 # fmt: skip reason | ||
x = 1 # fmt: skip - reason | ||
x = 1 # fmt: skip; noqa | ||
``` | ||
|
||
|
||
|