summaryrefslogtreecommitdiff
path: root/isort/isort.py
diff options
context:
space:
mode:
Diffstat (limited to 'isort/isort.py')
-rw-r--r--isort/isort.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/isort/isort.py b/isort/isort.py
index f8dbd108..114daf07 100644
--- a/isort/isort.py
+++ b/isort/isort.py
@@ -620,7 +620,6 @@ class SortImports(object):
while not self._at_end():
line = self._get_line()
skip_line = self._skip_line(line)
- on_first_import = False
if line in self._section_comments and not skip_line:
if self.import_index == -1:
@@ -651,7 +650,6 @@ class SortImports(object):
line = line.replace("\t", " ")
if self.import_index == -1:
self.import_index = self.index - 1
- on_first_import = True
nested_comments = {}
import_string, comments, new_comments = self._strip_comments(line)
@@ -708,7 +706,7 @@ class SortImports(object):
if comments:
self.comments['from'].setdefault(import_from, []).extend(comments)
last = self.out_lines and self.out_lines[-1].rstrip() or ""
- if (not on_first_import and last.startswith("#") and not last.endswith('"""') and not
+ if (len(self.out_lines) > self.import_index and last.startswith("#") and not last.endswith('"""') and not
last.endswith("'''")):
self.comments['above']['from'].setdefault(import_from, []).append(self.out_lines.pop(-1))
if root.get(import_from, False):
@@ -721,7 +719,7 @@ class SortImports(object):
self.comments['straight'][module] = comments
comments = None
last = self.out_lines and self.out_lines[-1].rstrip() or ""
- if (not on_first_import and last.startswith("#") and not
+ if (len(self.out_lines) > self.import_index and last.startswith("#") and not
last.endswith('"""') and not last.endswith("'''")):
self.comments['above']['from'][module] = self.out_lines.pop(-1)
self.imports[self.place_module(module)][import_type].add(module)