diff options
-rw-r--r-- | isort/api.py | 2 | ||||
-rw-r--r-- | tests/test_isort.py | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/isort/api.py b/isort/api.py index a5aec8cb..8d435b21 100644 --- a/isort/api.py +++ b/isort/api.py @@ -218,6 +218,8 @@ def sort_imports( elif stripped_line == "# isort: off": not_imports = True isort_off = True + elif stripped_line == "# isort: split": + not_imports = True elif not stripped_line or stripped_line.startswith("#"): import_section += line elif stripped_line.startswith(IMPORT_START_IDENTIFIERS): diff --git a/tests/test_isort.py b/tests/test_isort.py index ef0028e3..e5072b0f 100644 --- a/tests/test_isort.py +++ b/tests/test_isort.py @@ -4200,3 +4200,16 @@ import os from . import local """ assert SortImports(file_contents=test_input).output == test_input + + +def test_isort_split() -> None: + """Test the ability to split isort import sections""" + test_input = """import os +import sys + +# isort: split + +import os +import sys +""" + assert SortImports(file_contents=test_input).output == test_input |