-
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.
Infer indentation with imports when logical indent is absent
- Loading branch information
1 parent
921bc15
commit 2f5f393
Showing
6 changed files
with
553 additions
and
480 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
crates/ruff_linter/resources/test/fixtures/isort/two_space.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,10 @@ | ||
# If the file doesn't contain a logical indent token, we should still detect two-space indentation on imports. | ||
from math import ( | ||
sin, | ||
tan, | ||
cos, | ||
nan, | ||
pi, | ||
) | ||
|
||
del sin, cos, tan, pi, nan |
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
...ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.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_linter/src/rules/isort/mod.rs | ||
--- | ||
two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted | ||
| | ||
1 | # If the file doesn't contain a logical indent token, we should still detect two-space indentation on imports. | ||
2 | / from math import ( | ||
3 | | sin, | ||
4 | | tan, | ||
5 | | cos, | ||
6 | | nan, | ||
7 | | pi, | ||
8 | | ) | ||
9 | | | ||
10 | | del sin, cos, tan, pi, nan | ||
| |_^ I001 | ||
| | ||
= help: Organize imports | ||
|
||
ℹ Safe fix | ||
1 1 | # If the file doesn't contain a logical indent token, we should still detect two-space indentation on imports. | ||
2 2 | from math import ( | ||
3 |- sin, | ||
4 |- tan, | ||
5 3 | cos, | ||
6 4 | nan, | ||
7 5 | pi, | ||
6 |+ sin, | ||
7 |+ tan, | ||
8 8 | ) | ||
9 9 | | ||
10 10 | del sin, cos, tan, pi, nan |
Oops, something went wrong.