contrib/import-checker.py
changeset 24488 4b3fc46097f7
parent 24487 642d245ff537
child 24489 0f6594b0a4e2
--- a/contrib/import-checker.py	Fri Mar 27 18:50:39 2015 -0500
+++ b/contrib/import-checker.py	Fri Mar 27 19:25:40 2015 -0500
@@ -164,7 +164,7 @@
 
 
 def cyclekey(names):
-    return tuple(sorted(set(names)))
+    return tuple(sorted((names)))
 
 def check_one_mod(mod, imports, path=None, ignore=None):
     if path is None:
@@ -177,7 +177,7 @@
             i = mod.rsplit('.', 1)[0] + '.' + i
         if i in path:
             firstspot = path.index(i)
-            cycle = path[firstspot:] + [i]
+            cycle = path[firstspot:]
             if cyclekey(cycle) not in ignore:
                 raise CircularImport(cycle)
             continue
@@ -186,12 +186,12 @@
 def rotatecycle(cycle):
     """arrange a cycle so that the lexicographically first module listed first
 
-    >>> rotatecycle(['foo', 'bar', 'foo'])
+    >>> rotatecycle(['foo', 'bar'])
     ['bar', 'foo', 'bar']
     """
     lowest = min(cycle)
     idx = cycle.index(lowest)
-    return cycle[idx:-1] + cycle[:idx] + [lowest]
+    return cycle[idx:] + cycle[:idx] + [lowest]
 
 def find_cycles(imports):
     """Find cycles in an already-loaded import graph.