Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct group by package tokenization #2136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion isort/sorting.py
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions tests/unit/profiles/test_google.py
Expand Up @@ -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
"""
)

Expand Down