Show More
@@ -164,7 +164,7 class CircularImport(Exception): | |||
|
164 | 164 | |
|
165 | 165 | |
|
166 | 166 | def cyclekey(names): |
|
167 |
return tuple(sorted( |
|
|
167 | return tuple(sorted((names))) | |
|
168 | 168 | |
|
169 | 169 | def check_one_mod(mod, imports, path=None, ignore=None): |
|
170 | 170 | if path is None: |
@@ -177,7 +177,7 def check_one_mod(mod, imports, path=Non | |||
|
177 | 177 | i = mod.rsplit('.', 1)[0] + '.' + i |
|
178 | 178 | if i in path: |
|
179 | 179 | firstspot = path.index(i) |
|
180 |
cycle = path[firstspot:] |
|
|
180 | cycle = path[firstspot:] | |
|
181 | 181 | if cyclekey(cycle) not in ignore: |
|
182 | 182 | raise CircularImport(cycle) |
|
183 | 183 | continue |
@@ -186,12 +186,12 def check_one_mod(mod, imports, path=Non | |||
|
186 | 186 | def rotatecycle(cycle): |
|
187 | 187 | """arrange a cycle so that the lexicographically first module listed first |
|
188 | 188 | |
|
189 |
>>> rotatecycle(['foo', 'bar' |
|
|
189 | >>> rotatecycle(['foo', 'bar']) | |
|
190 | 190 | ['bar', 'foo', 'bar'] |
|
191 | 191 | """ |
|
192 | 192 | lowest = min(cycle) |
|
193 | 193 | idx = cycle.index(lowest) |
|
194 |
return cycle[idx: |
|
|
194 | return cycle[idx:] + cycle[:idx] + [lowest] | |
|
195 | 195 | |
|
196 | 196 | def find_cycles(imports): |
|
197 | 197 | """Find cycles in an already-loaded import graph. |
General Comments 0
You need to be logged in to leave comments.
Login now