summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--isort/settings.py2
-rw-r--r--tests/unit/test_isort.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/isort/settings.py b/isort/settings.py
index e0c8b98d..0d736d64 100644
--- a/isort/settings.py
+++ b/isort/settings.py
@@ -57,6 +57,8 @@ BLOCKED_EXTENSIONS = frozenset({"pex"})
FILE_SKIP_COMMENTS: Tuple[str, ...] = (
"# isort:" + "skip_file",
"# isort: " + "skip_file",
+ "#isort:" + "skip_file",
+ "#isort: " + "skip_file",
) # Concatenated to avoid this file being skipped
MAX_CONFIG_SEARCH_DEPTH: int = 25 # The number of parent directories to for a config file within
STOP_CONFIG_SEARCH_ON_DIRS: Tuple[str, ...] = (".git", ".hg")
diff --git a/tests/unit/test_isort.py b/tests/unit/test_isort.py
index 3467569f..c16a8436 100644
--- a/tests/unit/test_isort.py
+++ b/tests/unit/test_isort.py
@@ -837,6 +837,12 @@ def test_skip_within_file() -> None:
with pytest.raises(FileSkipped):
isort.code(test_input, known_third_party=["django"])
+def test_skip_comment_without_space_after_hash() -> None:
+ """Ensure skipping a whole file works."""
+ test_input = "#isort: skip_file\nimport django\nimport myproject\n"
+ with pytest.raises(FileSkipped):
+ isort.code(test_input, known_third_party=["django"])
+
def test_skip_comment_is_no_comment() -> None:
"""Ensure skipping a whole file works."""
test_input = "content = \"# isort:skip_file\""
@@ -849,7 +855,6 @@ def test_force_to_top() -> None:
test_output = isort.code(test_input, force_to_top=["lib5"])
assert test_output == "import lib5\nimport lib1\nimport lib2\nimport lib6\n"
-
def test_add_imports() -> None:
"""Ensures adding imports works as expected."""
test_input = "import lib6\nimport lib2\nimport lib5\nimport lib1\n\n"