forked from astral-sh/ruff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
unicode_width
to sort by length + add tests
The `UnicodeWidthStr` trait yields "displayed width of Unicode strings". Some tests with non-ASCII characters were added.
- Loading branch information
Showing
7 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
crates/ruff_linter/resources/test/fixtures/isort/length_sort_non_ascii_members.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,11 @@ | ||
from module1 import ( | ||
loooooooooooooong, | ||
σηορτ, | ||
mediuuuuum, | ||
shoort, | ||
looooooooooooooong, | ||
μεδιυυυυυμ, | ||
short, | ||
mediuuuuuum, | ||
λοοοοοοοοοοοοοονγ, | ||
) |
9 changes: 9 additions & 0 deletions
9
crates/ruff_linter/resources/test/fixtures/isort/length_sort_non_ascii_modules.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 @@ | ||
import loooooooooooooong | ||
import mediuuuuuum | ||
import short | ||
import σηορτ | ||
import shoort | ||
import mediuuuuum | ||
import λοοοοοοοοοοοοοονγ | ||
import μεδιυυυυυμ | ||
import looooooooooooooong |
3 changes: 3 additions & 0 deletions
3
crates/ruff_linter/resources/test/fixtures/isort/length_sort_with_star_import.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,3 @@ | ||
from looooooooooooooong import a | ||
from mediuuuum import * | ||
from short import * |
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
37 changes: 37 additions & 0 deletions
37
...hots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.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,37 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/isort/mod.rs | ||
--- | ||
length_sort_non_ascii_members.py:1:1: I001 [*] Import block is un-sorted or un-formatted | ||
| | ||
1 | / from module1 import ( | ||
2 | | loooooooooooooong, | ||
3 | | σηορτ, | ||
4 | | mediuuuuum, | ||
5 | | shoort, | ||
6 | | looooooooooooooong, | ||
7 | | μεδιυυυυυμ, | ||
8 | | short, | ||
9 | | mediuuuuuum, | ||
10 | | λοοοοοοοοοοοοοονγ, | ||
11 | | ) | ||
| | ||
= help: Organize imports | ||
|
||
ℹ Fix | ||
1 1 | from module1 import ( | ||
2 |- loooooooooooooong, | ||
2 |+ short, | ||
3 3 | σηορτ, | ||
4 |+ shoort, | ||
4 5 | mediuuuuum, | ||
5 |- shoort, | ||
6 |- looooooooooooooong, | ||
7 6 | μεδιυυυυυμ, | ||
8 |- short, | ||
9 7 | mediuuuuuum, | ||
8 |+ loooooooooooooong, | ||
10 9 | λοοοοοοοοοοοοοονγ, | ||
10 |+ looooooooooooooong, | ||
11 11 | ) | ||
|
||
|
32 changes: 32 additions & 0 deletions
32
...hots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.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 | ||
--- | ||
length_sort_non_ascii_modules.py:1:1: I001 [*] Import block is un-sorted or un-formatted | ||
| | ||
1 | / import loooooooooooooong | ||
2 | | import mediuuuuuum | ||
3 | | import short | ||
4 | | import σηορτ | ||
5 | | import shoort | ||
6 | | import mediuuuuum | ||
7 | | import λοοοοοοοοοοοοοονγ | ||
8 | | import μεδιυυυυυμ | ||
9 | | import looooooooooooooong | ||
| | ||
= help: Organize imports | ||
|
||
ℹ Fix | ||
1 |-import loooooooooooooong | ||
2 |-import mediuuuuuum | ||
3 1 | import short | ||
4 2 | import σηορτ | ||
5 3 | import shoort | ||
6 4 | import mediuuuuum | ||
5 |+import μεδιυυυυυμ | ||
6 |+import mediuuuuuum | ||
7 |+import loooooooooooooong | ||
7 8 | import λοοοοοοοοοοοοοονγ | ||
8 |-import μεδιυυυυυμ | ||
9 9 | import looooooooooooooong | ||
|
||
|
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