summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2021-04-15 23:30:28 -0700
committerTimothy Crosley <timothy.crosley@gmail.com>2021-04-15 23:30:28 -0700
commit09095a543a5bc3192118c0bd5c7f1e2f676af8af (patch)
tree9296e764af3166ae11248eee43819506e2dfc1f4
parentc8e6b6803addcd437279b1177d8870bc8e1dbb43 (diff)
downloadisort-issue/1208-namespace-import-from-support.tar.gz
-rw-r--r--isort/parse.py28
-rw-r--r--tests/unit/test_isort.py2
2 files changed, 15 insertions, 15 deletions
diff --git a/isort/parse.py b/isort/parse.py
index 0bb963b1..714e39ab 100644
--- a/isort/parse.py
+++ b/isort/parse.py
@@ -432,21 +432,21 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte
if type_of_import == "from":
import_from = just_imports.pop(0)
- for import_name in just_imports:
- placed_module = finder(f"{import_from}.{import_name}")
- if config.verbose and not config.only_modified:
- print(f"from-type place_module for {import_from} returned {placed_module}")
+ placed_module = finder(import_from)
+ if config.verbose and not config.only_modified:
+ print(f"from-type place_module for {import_from} returned {placed_module}")
- elif config.verbose:
- verbose_output.append(
- f"from-type place_module for {import_from} returned {placed_module}"
- )
- if placed_module == "":
- warn(
- f"could not place module {import_from} of line {line} --"
- " Do you need to define a default section?"
- )
- root = imports[placed_module][type_of_import] # type: ignore
+ elif config.verbose:
+ verbose_output.append(
+ f"from-type place_module for {import_from} returned {placed_module}"
+ )
+ if placed_module == "":
+ warn(
+ f"could not place module {import_from} of line {line} --"
+ " Do you need to define a default section?"
+ )
+ root = imports[placed_module][type_of_import] # type: ignore
+ for import_name in just_imports:
associated_comment = nested_comments.get(import_name)
if associated_comment:
categorized_comments["nested"].setdefault(import_from, {})[
diff --git a/tests/unit/test_isort.py b/tests/unit/test_isort.py
index 62b99231..7a02884b 100644
--- a/tests/unit/test_isort.py
+++ b/tests/unit/test_isort.py
@@ -1038,8 +1038,8 @@ def test_forced_separate() -> None:
"from django.core.urlresolvers import reverse\n"
"from django.db import models\n"
"from django.db.models.fields import FieldDoesNotExist\n"
- "\n"
"from django.utils import six\n"
+ "\n"
"from django.utils.deprecation import RenameMethodsBase\n"
"from django.utils.encoding import force_str, force_text\n"
"from django.utils.http import urlencode\n"