Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/isort/two_space.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

print("brace {} %s" % (1,))

print((
"foo %s "
"bar %s" % (x, y)
))

print(
"%s" % (
"trailing comma",
Expand All @@ -52,10 +57,6 @@

print("%(a)s" % {"a" : 1})

print((
"foo %s "
"bar %s" % (x, y)
))

print(
"foo %(foo)s "
Expand Down
1 change: 1 addition & 0 deletions crates/ruff_linter/src/rules/isort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ mod tests {
#[test_case(Path::new("split.py"))]
#[test_case(Path::new("star_before_others.py"))]
#[test_case(Path::new("trailing_suffix.py"))]
#[test_case(Path::new("two_space.py"))]
#[test_case(Path::new("type_comments.py"))]
#[test_case(Path::new("unicode.py"))]
fn default(path: &Path) -> Result<()> {
Expand Down
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
Loading