diff options
Diffstat (limited to 'isort/parse.py')
-rw-r--r-- | isort/parse.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/isort/parse.py b/isort/parse.py index a87461ff..6089c08b 100644 --- a/isort/parse.py +++ b/isort/parse.py @@ -54,7 +54,7 @@ def _normalize_line(raw_line: str) -> Tuple[str, str]: def import_type(line: str) -> Optional[str]: """If the current line is an import line it will return its type (from or straight)""" - if "isort:skip" in line or "NOQA" in line: + if "isort:skip" in line or "isort: skip" in line or "NOQA" in line: return None elif line.startswith("import "): return "straight" @@ -174,6 +174,10 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte section = line.split("isort:imports-")[-1].split()[0].upper() place_imports[section] = [] import_placements[line] = section + elif "isort: imports-" in line and line.startswith("#"): + section = line.split("isort: imports-")[-1].split()[0].upper() + place_imports[section] = [] + import_placements[line] = section if skipping_line: out_lines.append(line) @@ -325,6 +329,7 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte and not last.endswith('"""') and not last.endswith("'''") and "isort:imports-" not in last + and "isort: imports-" not in last ): categorized_comments["above"]["from"].setdefault(import_from, []).insert( 0, out_lines.pop(-1) @@ -361,6 +366,7 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte and not last.endswith('"""') and not last.endswith("'''") and "isort:imports-" not in last + and "isort: imports-" not in last ): categorized_comments["above"]["straight"].setdefault(module, []).insert( 0, out_lines.pop(-1) |