def _get_modules(module):
    """
    Takes a list of modules and converts into a string.

    The module list can include parens, this function checks each element in
    the list, if there is a paren then it does not add a comma before the next
    element. Otherwise a comma and space is added. This is to preserve module
    imports which are multi-line and/or occur within parens. While also not
    affecting imports which are not enclosed.
    """
    modules_string = [cur + ', ' if cur.isalnum() and next.isalnum()
                      else cur
                      for (cur, next) in zip(module, module[1:]+[''])]

    return ''.join(modules_string)