Skip to content

Commit

Permalink
Initial approach for fixing handling of as mixed with non as imports …
Browse files Browse the repository at this point in the history
…of same path
  • Loading branch information
timothycrosley committed Oct 5, 2020
1 parent 080a903 commit 0971e63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions isort/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0971e63

Please sign in to comment.