summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2015-02-05 17:46:28 -0500
committerTimothy Crosley <timothy.crosley@gmail.com>2015-02-05 17:46:28 -0500
commit139822f6958fee30424574d3621964214a43fae1 (patch)
tree50b5a45f29ce24328f4a9134a72fdd50b2568b0d
parentfdbd2e34ab0c753ef7e0af9a8aaa713efe23980a (diff)
downloadisort-139822f6958fee30424574d3621964214a43fae1.tar.gz
Attempt 3 to fix inconsitencuy
-rw-r--r--isort/isort.py13
1 files changed, 4 insertions, 9 deletions
diff --git a/isort/isort.py b/isort/isort.py
index 9703de8f..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
@@ -258,7 +259,7 @@ class SortImports(object):
return self.index == self.number_of_lines
@staticmethod
- def _module_key(module_name, config, sub_imports=False, already_sorted=None):
+ def _module_key(module_name, config, sub_imports=False):
prefix = ""
module_name = str(module_name)
if sub_imports and config['order_by_type']:
@@ -269,11 +270,6 @@ class SortImports(object):
else:
prefix = "C"
module_name = module_name.lower()
- if already_sorted:
- if module_name in already_sorted:
- module_name = moudle_name + "a"
- already_sorted.append(module_name)
-
return "{0}{1}{2}".format(module_name in config['force_to_top'] and "A" or "B", prefix,
config['length_sort'] and (str(len(module_name)) + ":" + module_name) or module_name)
@@ -431,8 +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())
- already_sorted = []
- from_modules = natsorted(from_modules, key=lambda key: self._module_key(key, self.config, already_sorted))
+ from_modules = natsorted(from_modules, key=lambda key: self._module_key(key, self.config, ))
section_output = []
if self.config.get('from_first', False):