summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2019-12-28 02:19:19 -0800
committerTimothy Crosley <timothy.crosley@gmail.com>2019-12-28 02:19:19 -0800
commitd5a9bf6710270f76573d018de73c7f06e4db9852 (patch)
tree67857c3e7fabd9df2587f8f4076d1836b639c86e
parente7cef3c941e0cbdd8b2c71cc6c7f2007b0be51ad (diff)
downloadisort-d5a9bf6710270f76573d018de73c7f06e4db9852.tar.gz
Add isort: split action with test casefeature/isort-skip-support
-rw-r--r--isort/api.py2
-rw-r--r--tests/test_isort.py13
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