summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Edmund Crosley <timothy.crosley@gmail.com>2015-02-05 17:54:12 -0500
committerTimothy Edmund Crosley <timothy.crosley@gmail.com>2015-02-05 17:54:12 -0500
commit947adf17b343a13f8ebf14401d007a8031259379 (patch)
tree50b5a45f29ce24328f4a9134a72fdd50b2568b0d
parent0a6a4af6e523a803a521713120ecbeed6622621e (diff)
parent139822f6958fee30424574d3621964214a43fae1 (diff)
downloadisort-947adf17b343a13f8ebf14401d007a8031259379.tar.gz
Merge pull request #245 from timothycrosley/feature/fix-issue-223
Enforce consistency
-rw-r--r--isort/isort.py5
-rw-r--r--test_isort.py2
2 files changed, 4 insertions, 3 deletions
diff --git a/isort/isort.py b/isort/isort.py
index f08dbc05..8ce51a4d 100644
--- a/isort/isort.py
+++ b/isort/isort.py
@@ -37,6 +37,7 @@ from sys import path as PYTHONPATH
from sys import stderr, stdout
from natsort import natsorted
+from pies.collections import OrderedDict
from pies.overrides import *
from . import settings
@@ -111,7 +112,7 @@ class SortImports(object):
self.imports = {}
self.as_map = {}
for section in itertools.chain(SECTIONS, self.config['forced_separate']):
- self.imports[section] = {'straight': set(), 'from': {}}
+ self.imports[section] = {'straight': set(), 'from': OrderedDict()}
self.index = 0
self.import_index = -1
@@ -426,7 +427,7 @@ class SortImports(object):
straight_modules = list(self.imports[section]['straight'])
straight_modules = natsorted(straight_modules, key=lambda key: self._module_key(key, self.config))
from_modules = list(self.imports[section]['from'].keys())
- from_modules = natsorted(from_modules, key=lambda key: self._module_key(key, self.config))
+ from_modules = natsorted(from_modules, key=lambda key: self._module_key(key, self.config, ))
section_output = []
if self.config.get('from_first', False):
diff --git a/test_isort.py b/test_isort.py
index 63b3a816..2aeb474c 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -1251,4 +1251,4 @@ def test_top_comments():
def test_consistency():
"""Ensures consistency of handling even when dealing with non ordered-by-type imports"""
test_input = "from sqlalchemy.dialects.postgresql import ARRAY, array\n"
- assert SortImports(file_contents=test_input, order_by_type=True).output == test_input
+ assert SortImports(file_contents=test_input, order_by_type=False).output == test_input