mirror of https://github.com/astral-sh/ruff
Make organize imports an automatic edit (#4744)
This commit is contained in:
parent
e1b6f6e57e
commit
d4e54cff05
|
|
@ -147,16 +147,15 @@ pub(crate) fn organize_imports(
|
||||||
let range = TextRange::new(locator.line_start(range.start()), trailing_line_end);
|
let range = TextRange::new(locator.line_start(range.start()), trailing_line_end);
|
||||||
let actual = locator.slice(range);
|
let actual = locator.slice(range);
|
||||||
if matches_ignoring_indentation(actual, &expected) {
|
if matches_ignoring_indentation(actual, &expected) {
|
||||||
None
|
return None;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
let mut diagnostic = Diagnostic::new(UnsortedImports, range);
|
let mut diagnostic = Diagnostic::new(UnsortedImports, range);
|
||||||
if settings.rules.should_fix(diagnostic.kind.rule()) {
|
if settings.rules.should_fix(diagnostic.kind.rule()) {
|
||||||
#[allow(deprecated)]
|
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
|
||||||
indent(&expected, indentation),
|
indent(&expected, indentation),
|
||||||
range,
|
range,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
Some(diagnostic)
|
Some(diagnostic)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | import sys
|
1 1 | import sys
|
||||||
2 |+
|
2 |+
|
||||||
3 |+import foo
|
3 |+import foo
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | import sys
|
1 1 | import sys
|
||||||
2 |+
|
2 |+
|
||||||
2 3 | import baz
|
2 3 | import baz
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ add_newline_before_comments.py:1:1: I001 [*] Import block is un-sorted or un-for
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | import os
|
1 1 | import os
|
||||||
2 |+
|
2 |+
|
||||||
2 3 | # This is a comment in the same section, so we need to add one newline.
|
2 3 | # This is a comment in the same section, so we need to add one newline.
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ as_imports_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from foo import ( # Comment on `foo`
|
1 |-from foo import ( # Comment on `foo`
|
||||||
2 |- Member as Alias, # Comment on `Alias`
|
2 |- Member as Alias, # Comment on `Alias`
|
||||||
3 |-)
|
3 |-)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ relative_imports_order.py:1:1: I001 [*] Import block is un-sorted or un-formatte
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |+from . import c
|
1 |+from . import c
|
||||||
2 |+from .. import b
|
2 |+from .. import b
|
||||||
1 3 | from ... import a
|
1 3 | from ... import a
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |+from module import CONSTANT, function
|
1 |+from module import CONSTANT, function
|
||||||
1 2 | from module import Class as C
|
1 2 | from module import Class as C
|
||||||
2 |-from module import CONSTANT
|
2 |-from module import CONSTANT
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from module import Class as C
|
1 |-from module import Class as C
|
||||||
2 |-from module import CONSTANT
|
2 |-from module import CONSTANT
|
||||||
3 |-from module import function
|
3 |-from module import function
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ combine_import_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from collections import Awaitable
|
1 |-from collections import Awaitable
|
||||||
2 |-from collections import AsyncIterable
|
2 |-from collections import AsyncIterable
|
||||||
3 |-from collections import Collection
|
3 |-from collections import Collection
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ comments.py:3:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | # Comment 1
|
1 1 | # Comment 1
|
||||||
2 2 | # Comment 2
|
2 2 | # Comment 2
|
||||||
3 |-import D
|
3 |-import D
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ deduplicate_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | import os
|
1 1 | import os
|
||||||
2 |-import os
|
2 |-import os
|
||||||
3 2 | import os as os1
|
3 2 | import os as os1
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ fit_line_length.py:7:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
5 5 |
|
5 5 |
|
||||||
6 6 | if indented:
|
6 6 | if indented:
|
||||||
7 7 | from line_with_88 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
7 7 | from line_with_88 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ fit_line_length_comment.py:1:1: I001 [*] Import block is un-sorted or un-formatt
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | import a
|
1 1 | import a
|
||||||
2 |+
|
2 |+
|
||||||
2 3 | # Don't take this comment into account when determining whether the next import can fit on one line.
|
2 3 | # Don't take this comment into account when determining whether the next import can fit on one line.
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ force_single_line.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-import sys, math
|
1 |-import sys, math
|
||||||
2 |-from os import path, uname
|
2 |-from os import path, uname
|
||||||
1 |+import math
|
1 |+import math
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from a import a1 # import_from
|
1 |-from a import a1 # import_from
|
||||||
2 |-from c import * # import_from_star
|
2 |-from c import * # import_from_star
|
||||||
3 1 | import a # import
|
3 1 | import a # import
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from a import a1 # import_from
|
1 |-from a import a1 # import_from
|
||||||
2 |-from c import * # import_from_star
|
2 |-from c import * # import_from_star
|
||||||
1 |+import z
|
1 |+import z
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-import lib6
|
1 |-import lib6
|
||||||
1 |+import foo
|
1 |+import foo
|
||||||
2 |+import lib1
|
2 |+import lib1
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-import lib6
|
1 |-import lib6
|
||||||
2 |-import lib2
|
2 |-import lib2
|
||||||
3 |-import lib5
|
3 |-import lib5
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ force_wrap_aliases.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from .a import a1 as a1, a2 as a2
|
1 |-from .a import a1 as a1, a2 as a2
|
||||||
1 |+from .a import a1 as a1
|
1 |+from .a import a1 as a1
|
||||||
2 |+from .a import a2 as a2
|
2 |+from .a import a2 as a2
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ force_wrap_aliases.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from .a import a1 as a1, a2 as a2
|
1 |-from .a import a1 as a1, a2 as a2
|
||||||
1 |+from .a import (
|
1 |+from .a import (
|
||||||
2 |+ a1 as a1,
|
2 |+ a1 as a1,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ forced_separate.py:3:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | # office_helper and tests are both first-party,
|
1 1 | # office_helper and tests are both first-party,
|
||||||
2 2 | # but we want tests and experiments to be separated, in that order
|
2 2 | # but we want tests and experiments to be separated, in that order
|
||||||
3 |+from office_helper.assistants import entity_registry as er
|
3 |+from office_helper.assistants import entity_registry as er
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import_from_after_import.py:1:1: I001 [*] Import block is un-sorted or un-format
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |+import os
|
1 |+import os
|
||||||
1 2 | from collections import Collection
|
1 2 | from collections import Collection
|
||||||
2 |-import os
|
2 |-import os
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | from a.prometheus.metrics import ( # type:ignore[attr-defined]
|
1 1 | from a.prometheus.metrics import ( # type:ignore[attr-defined]
|
||||||
2 2 | TERMINAL_CURRENTLY_RUNNING_TOTAL,
|
2 2 | TERMINAL_CURRENTLY_RUNNING_TOTAL,
|
||||||
3 3 | )
|
3 3 | )
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ insert_empty_lines.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | import a
|
1 1 | import a
|
||||||
2 2 | import b
|
2 2 | import b
|
||||||
3 |+
|
3 |+
|
||||||
|
|
@ -33,7 +33,7 @@ insert_empty_lines.py:4:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
3 3 | x = 1
|
3 3 | x = 1
|
||||||
4 4 | import os
|
4 4 | import os
|
||||||
5 5 | import sys
|
5 5 | import sys
|
||||||
|
|
@ -56,7 +56,7 @@ insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
13 13 | y = 1
|
13 13 | y = 1
|
||||||
14 14 | import os
|
14 14 | import os
|
||||||
15 15 | import sys
|
15 15 | import sys
|
||||||
|
|
@ -76,7 +76,7 @@ insert_empty_lines.py:52:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
51 51 |
|
51 51 |
|
||||||
52 52 | import os
|
52 52 | import os
|
||||||
53 53 |
|
53 53 |
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ insert_empty_lines.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | import a
|
1 1 | import a
|
||||||
2 2 | import b
|
2 2 | import b
|
||||||
3 |+
|
3 |+
|
||||||
|
|
@ -33,7 +33,7 @@ insert_empty_lines.pyi:4:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
3 3 | x = 1
|
3 3 | x = 1
|
||||||
4 4 | import os
|
4 4 | import os
|
||||||
5 5 | import sys
|
5 5 | import sys
|
||||||
|
|
@ -55,7 +55,7 @@ insert_empty_lines.pyi:14:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
13 13 | y = 1
|
13 13 | y = 1
|
||||||
14 14 | import os
|
14 14 | import os
|
||||||
15 15 | import sys
|
15 15 | import sys
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |+import os
|
1 |+import os
|
||||||
1 2 | import sys
|
1 2 | import sys
|
||||||
3 |+
|
3 |+
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
2 2 |
|
2 2 |
|
||||||
3 3 | from typing import Any
|
3 3 | from typing import Any
|
||||||
4 4 |
|
4 4 |
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un-
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
2 2 |
|
2 2 |
|
||||||
3 3 | from typing import Any
|
3 3 | from typing import Any
|
||||||
4 4 |
|
4 4 |
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ lines_after_imports_nothing_after.py:1:1: I001 [*] Import block is un-sorted or
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
2 2 |
|
2 2 |
|
||||||
3 3 | from typing import Any
|
3 3 | from typing import Any
|
||||||
4 4 |
|
4 4 |
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ lines_between_types.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
9 9 | import requests
|
9 9 | import requests
|
||||||
10 10 |
|
10 10 |
|
||||||
11 11 |
|
11 11 |
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line
|
1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line
|
||||||
2 |-from sys import (
|
2 |-from sys import (
|
||||||
3 |- stderr,
|
3 |- stderr,
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ natural_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | import numpy1
|
1 1 | import numpy1
|
||||||
2 |+import numpy2
|
2 |+import numpy2
|
||||||
2 3 | import numpy10
|
2 3 | import numpy10
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
2 2 |
|
2 2 |
|
||||||
3 3 | from typing import Any
|
3 3 | from typing import Any
|
||||||
4 4 |
|
4 4 |
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | from __future__ import annotations
|
1 1 | from __future__ import annotations
|
||||||
2 |-
|
2 |-
|
||||||
3 2 | from typing import Any
|
3 2 | from typing import Any
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ no_lines_before_with_empty_sections.py:1:1: I001 [*] Import block is un-sorted o
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | from __future__ import annotations
|
1 1 | from __future__ import annotations
|
||||||
2 2 | from typing import Any
|
2 2 | from typing import Any
|
||||||
3 |+
|
3 |+
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ no_wrap_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore
|
1 |-from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore
|
||||||
1 |+from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore
|
1 |+from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-import StringIO
|
1 |-import StringIO
|
||||||
2 1 | import glob
|
2 1 | import glob
|
||||||
3 2 | import os
|
3 2 | import os
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-import StringIO
|
1 |-import StringIO
|
||||||
2 1 | import glob
|
2 1 | import glob
|
||||||
3 2 | import os
|
3 2 | import os
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from sklearn.svm import func, SVC, CONST, Klass
|
1 |-from sklearn.svm import func, SVC, CONST, Klass
|
||||||
2 |-from subprocess import N_CLASS, PIPE, Popen, STDOUT
|
2 |-from subprocess import N_CLASS, PIPE, Popen, STDOUT
|
||||||
3 |-from module import CLASS, Class, CONSTANT, function, BASIC, Apple
|
3 |-from module import CLASS, Class, CONSTANT, function, BASIC, Apple
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from sklearn.svm import func, SVC, CONST, Klass
|
1 |-from sklearn.svm import func, SVC, CONST, Klass
|
||||||
2 |-from subprocess import N_CLASS, PIPE, Popen, STDOUT
|
2 |-from subprocess import N_CLASS, PIPE, Popen, STDOUT
|
||||||
3 |-from module import CLASS, Class, CONSTANT, function, BASIC, Apple
|
3 |-from module import CLASS, Class, CONSTANT, function, BASIC, Apple
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ order_by_type_with_custom_constants.py:1:1: I001 [*] Import block is un-sorted o
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant
|
1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant
|
||||||
2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT
|
2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT
|
||||||
1 |+from subprocess import STDOUT, A_constant, Class, First, Last, func, konst, var
|
1 |+from subprocess import STDOUT, A_constant, Class, First, Last, func, konst, var
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ order_by_type_with_custom_constants.py:1:1: I001 [*] Import block is un-sorted o
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant
|
1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant
|
||||||
2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT
|
2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT
|
||||||
1 |+from subprocess import A_constant, First, konst, Last, STDOUT, Class, func, var
|
1 |+from subprocess import A_constant, First, konst, Last, STDOUT, Class, func, var
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ order_by_type_with_custom_variables.py:1:1: I001 [*] Import block is un-sorted o
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc
|
1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc
|
||||||
2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe
|
2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe
|
||||||
1 |+from subprocess import CONSTANT, Klass, Variable, exe, utils, var_ABC
|
1 |+from subprocess import CONSTANT, Klass, Variable, exe, utils, var_ABC
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ order_by_type_with_custom_variables.py:1:1: I001 [*] Import block is un-sorted o
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc
|
1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc
|
||||||
2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe
|
2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe
|
||||||
1 |+from subprocess import CONSTANT, Klass, exe, utils, var_ABC, Variable
|
1 |+from subprocess import CONSTANT, Klass, exe, utils, var_ABC, Variable
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ order_relative_imports_by_level.py:1:1: I001 [*] Import block is un-sorted or un
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from .a import a
|
1 |-from .a import a
|
||||||
2 1 | from ..a import a
|
2 1 | from ..a import a
|
||||||
3 2 | from ..b import a
|
3 2 | from ..b import a
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ preserve_comment_order.py:1:1: I001 [*] Import block is un-sorted or un-formatte
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |+import abc
|
1 |+import abc
|
||||||
1 2 | import io
|
1 2 | import io
|
||||||
3 |+
|
3 |+
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ preserve_import_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from some_other_module import some_class
|
1 |-from some_other_module import some_class
|
||||||
2 |-from some_other_module import *
|
2 |-from some_other_module import *
|
||||||
3 1 | # Above
|
3 1 | # Above
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ preserve_indentation.py:2:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | if True:
|
1 1 | if True:
|
||||||
2 |+ import os
|
2 |+ import os
|
||||||
2 3 | import sys
|
2 3 | import sys
|
||||||
|
|
@ -31,7 +31,7 @@ preserve_indentation.py:5:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
2 2 | import sys
|
2 2 | import sys
|
||||||
3 3 | import os
|
3 3 | import os
|
||||||
4 4 | else:
|
4 4 | else:
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ propagate_inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-forma
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | from mypackage.subpackage import ( # long comment that seems to be a problem
|
1 1 | from mypackage.subpackage import ( # long comment that seems to be a problem
|
||||||
2 2 | a_long_variable_name_that_causes_problems,
|
2 2 | a_long_variable_name_that_causes_problems,
|
||||||
3 |- items,
|
3 |- items,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ reorder_within_section.py:1:1: I001 [*] Import block is un-sorted or un-formatte
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |+import os
|
1 |+import os
|
||||||
1 2 | import sys
|
1 2 | import sys
|
||||||
2 |-import os
|
2 |-import os
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | from __future__ import annotations
|
1 1 | from __future__ import annotations
|
||||||
2 |+
|
2 |+
|
||||||
2 3 | import os
|
2 3 | import os
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | from __future__ import annotations
|
1 1 | from __future__ import annotations
|
||||||
2 |+
|
2 |+
|
||||||
2 3 | import os
|
2 3 | import os
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ separate_first_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |+import os
|
1 |+import os
|
||||||
1 2 | import sys
|
1 2 | import sys
|
||||||
3 |+
|
3 |+
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ separate_future_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatt
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-import sys
|
1 |-import sys
|
||||||
2 |-import os
|
2 |-import os
|
||||||
3 1 | from __future__ import annotations
|
3 1 | from __future__ import annotations
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |+import os
|
1 |+import os
|
||||||
1 2 | import sys
|
1 2 | import sys
|
||||||
3 |+
|
3 |+
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ separate_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-import pandas as pd
|
1 |-import pandas as pd
|
||||||
1 |+import os
|
1 |+import os
|
||||||
2 2 | import sys
|
2 2 | import sys
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ skip.py:20:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
17 17 | def f():
|
17 17 | def f():
|
||||||
18 18 | import sys
|
18 18 | import sys
|
||||||
19 19 | import os # isort: skip
|
19 19 | import os # isort: skip
|
||||||
|
|
@ -34,7 +34,7 @@ skip.py:27:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
24 24 | def f():
|
24 24 | def f():
|
||||||
25 25 | import sys
|
25 25 | import sys
|
||||||
26 26 | import os # isort:skip
|
26 26 | import os # isort:skip
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ sort_similar_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 |-from a import b
|
1 |-from a import b
|
||||||
1 |+import A
|
1 |+import A
|
||||||
2 |+import a
|
2 |+import a
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ split.py:15:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
12 12 | import b
|
12 12 | import b
|
||||||
13 13 |
|
13 13 |
|
||||||
14 14 | if True:
|
14 14 | if True:
|
||||||
|
|
@ -32,7 +32,7 @@ split.py:20:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
17 17 |
|
17 17 |
|
||||||
18 18 | # isort: split
|
18 18 | # isort: split
|
||||||
19 19 |
|
19 19 |
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line
|
1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line
|
||||||
2 |-from sys import (
|
2 |-from sys import (
|
||||||
3 |- stderr,
|
3 |- stderr,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ star_before_others.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
||||||
|
|
|
|
||||||
= help: Organize imports
|
= help: Organize imports
|
||||||
|
|
||||||
ℹ Suggested fix
|
ℹ Fix
|
||||||
1 1 | from .logging import config_logging
|
1 1 | from .logging import config_logging
|
||||||
2 |+from .settings import *
|
2 |+from .settings import *
|
||||||
2 3 | from .settings import ENV
|
2 3 | from .settings import ENV
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue