def inner_problem_check(problems, done, verbosity):
 result = []
 for (last, migration) in problems:
  checked = set([])
  to_check = list(last.dependencies)
  while to_check:
   checking = to_check.pop()
   if (checking in checked):
    continue
   checked.add(checking)
   if (checking not in done):
    if verbosity:
     print((' ! Migration %s should not have been applied before %s but was.' % (last, checking)))
    result.append((last, checking))
   else:
    to_check.extend(checking.dependencies)
 return result

def inner_problem_check ( problems , done , verbosity ) : result = [ ] for ( last , migration ) in problems : checked = set ( [ ] ) to_check = list ( last . dependencies ) while to_check : checking = to_check . pop ( ) if ( checking in checked ) : continue checked . add ( checking ) if ( checking not in done ) : if verbosity : print ( ( ' ! Migration %s should not have been applied before %s but was.' % ( last , checking ) ) ) result . append ( ( last , checking ) ) else : to_check . extend ( checking . dependencies ) return result
takes a set of possible problems and gets the actual issues out of it .