From 3d0efc108cb79b7c6d74515d126746b2ef08733b Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 19 May 2023 13:48:52 +1000 Subject: [PATCH] fix: correct group by package tokenization fixes #2135 --- isort/sorting.py | 2 +- tests/unit/profiles/test_google.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/isort/sorting.py b/isort/sorting.py index 7ad70b221..976f00e44 100644 --- a/isort/sorting.py +++ b/isort/sorting.py @@ -66,7 +66,7 @@ def section_key(line: str, config: Config) -> str: if match: # pragma: no cover - regex always matches if line starts with "from ." line = f"from {' '.join(match.groups())}" if config.group_by_package and line.strip().startswith("from"): - line = line.split(" import", 1)[0] + line = line.split(" import ", 1)[0] if config.lexicographical: line = _import_line_intro_re.sub("", _import_line_midline_import_re.sub(".", line)) diff --git a/tests/unit/profiles/test_google.py b/tests/unit/profiles/test_google.py index 4a3b41313..b265e3095 100644 --- a/tests/unit/profiles/test_google.py +++ b/tests/unit/profiles/test_google.py @@ -17,6 +17,7 @@ def test_google_code_snippet_shared_example(): google_isort_test( """from a import z from a.b import c +from a.b import import_me """ )