Skip to content

Commit

Permalink
Remove the all_are_submodules handling
Browse files Browse the repository at this point in the history
  • Loading branch information
msullivan committed Feb 27, 2018
1 parent 7e22778 commit c21e216
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,23 +658,15 @@ def correct_rel_imp(imp: Union[ImportFrom, ImportAll]) -> str:
elif isinstance(imp, ImportFrom):
cur_id = correct_rel_imp(imp)
pos = len(res)
all_are_submodules = True
# Also add any imported names that are submodules.
pri = import_priority(imp, PRI_MED)
for name, __ in imp.names:
sub_id = cur_id + '.' + name
if self.is_module(sub_id):
res.append((pri, sub_id, imp.line))
else:
all_are_submodules = False
# If all imported names are submodules, don't add
# cur_id as a dependency. Otherwise (i.e., if at
# least one imported name isn't a submodule)
# cur_id is also a dependency, and we should
# insert it *before* any submodules.
if not all_are_submodules:
pri = import_priority(imp, PRI_HIGH)
res.insert(pos, ((pri, cur_id, imp.line)))

pri = import_priority(imp, PRI_HIGH)
res.insert(pos, ((pri, cur_id, imp.line)))
elif isinstance(imp, ImportAll):
pri = import_priority(imp, PRI_HIGH)
res.append((pri, correct_rel_imp(imp), imp.line))
Expand Down

0 comments on commit c21e216

Please sign in to comment.