diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2020-10-04 21:08:15 -0700 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2020-10-04 21:08:15 -0700 |
commit | 0971e635720ea3af4ecd2c18b8359dd30e2b8218 (patch) | |
tree | a7a45633cf5f15e82dc3ad366926c985606355a7 | |
parent | 080a9038ee4ccefdf6b70800c10e40836e4015cc (diff) | |
download | isort-issue/1523/isort-removes-non-as-imports-on-same-line.tar.gz |
Initial approach for fixing handling of as mixed with non as imports of same pathissue/1523/isort-removes-non-as-imports-on-same-line
-rw-r--r-- | isort/parse.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/isort/parse.py b/isort/parse.py index 9348267c..d7e22a2d 100644 --- a/isort/parse.py +++ b/isort/parse.py @@ -336,10 +336,10 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte item.replace("{|", "{ ").replace("|}", " }") for item in _strip_syntax(import_string).split() ] - straight_import = True + attach_comments_to: Optional[List[Any]] = None if "as" in just_imports and (just_imports.index("as") + 1) < len(just_imports): - straight_import = False + straight_imports = set() while "as" in just_imports: nested_module = None as_index = just_imports.index("as") @@ -379,6 +379,8 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte module, [] ) del just_imports[as_index : as_index + 2] + else: + straight_imports = set(just_imports[1:]) if type_of_import == "from": import_from = just_imports.pop(0) |