mirror of https://github.com/astral-sh/ruff
parent
a9cc56b2ac
commit
16d933fcf5
|
|
@ -1,10 +1,20 @@
|
|||
# isort: off
|
||||
import sys
|
||||
import os
|
||||
import collections
|
||||
# isort: on
|
||||
def f():
|
||||
# isort: off
|
||||
import sys
|
||||
import os
|
||||
import collections
|
||||
# isort: on
|
||||
|
||||
import sys
|
||||
import os # isort: skip
|
||||
import collections
|
||||
import abc
|
||||
|
||||
def f():
|
||||
import sys
|
||||
import os # isort: skip
|
||||
import collections
|
||||
import abc
|
||||
|
||||
|
||||
def f():
|
||||
import sys
|
||||
import os # isort:skip
|
||||
import collections
|
||||
import abc
|
||||
|
|
|
|||
|
|
@ -104,10 +104,13 @@ pub fn extract_isort_directives(lxr: &[LexResult]) -> IsortDirectives {
|
|||
continue;
|
||||
};
|
||||
|
||||
// `isort` allows for `# isort: skip` and `# isort: skip_file` to include or
|
||||
// omit a space after the colon. The remaining action comments are
|
||||
// required to include the space, and must appear on their own lines.
|
||||
let comment_text = comment_text.trim_end();
|
||||
if comment_text == "# isort: split" {
|
||||
splits.push(start.row());
|
||||
} else if comment_text == "# isort: skip_file" {
|
||||
} else if comment_text == "# isort: skip_file" || comment_text == "# isort:skip_file" {
|
||||
skip_file = true;
|
||||
} else if off.is_some() {
|
||||
if comment_text == "# isort: on" {
|
||||
|
|
@ -119,7 +122,7 @@ pub fn extract_isort_directives(lxr: &[LexResult]) -> IsortDirectives {
|
|||
off = None;
|
||||
}
|
||||
} else {
|
||||
if comment_text.contains("isort: skip") {
|
||||
if comment_text.contains("isort: skip") || comment_text.contains("isort:skip") {
|
||||
exclusions.insert(start.row());
|
||||
} else if comment_text == "# isort: off" {
|
||||
off = Some(start);
|
||||
|
|
|
|||
|
|
@ -5,35 +5,35 @@ expression: checks
|
|||
- kind:
|
||||
UnsortedImports: ~
|
||||
location:
|
||||
row: 7
|
||||
row: 12
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
row: 14
|
||||
column: 0
|
||||
fix:
|
||||
content: "import sys\n\n"
|
||||
content: " import abc\n import collections\n"
|
||||
location:
|
||||
row: 7
|
||||
row: 12
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
row: 14
|
||||
column: 0
|
||||
parent: ~
|
||||
- kind:
|
||||
UnsortedImports: ~
|
||||
location:
|
||||
row: 9
|
||||
row: 19
|
||||
column: 0
|
||||
end_location:
|
||||
row: 11
|
||||
row: 21
|
||||
column: 0
|
||||
fix:
|
||||
content: "import abc\nimport collections\n"
|
||||
content: " import abc\n import collections\n"
|
||||
location:
|
||||
row: 9
|
||||
row: 19
|
||||
column: 0
|
||||
end_location:
|
||||
row: 11
|
||||
row: 21
|
||||
column: 0
|
||||
parent: ~
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue