summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2015-02-05 12:37:08 -0500
committerTimothy Crosley <timothy.crosley@gmail.com>2015-02-05 12:37:08 -0500
commite1b2f3cd9e59ee006c638df182feb7850f625dfe (patch)
tree32569ebe8ab85deb0edfe5e29ce1ad11c64d9e3e
parente129a2e1002f192fe9f5ea0966e7dbf4efe46487 (diff)
downloadisort-e1b2f3cd9e59ee006c638df182feb7850f625dfe.tar.gz
Fix isort to pass additional test
-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)