import ast


def _pull_stmt(stmt):
  """Pulls the first stmt from an AST for a Python module."""
  if not isinstance(stmt, ast.Module):
    raise ValueError('statement/expression has unexpected type %r: %s' %
                     (type(stmt), ast.dump(stmt)))
  if len(stmt.body) != 1:
    raise ValueError(
        'statement/expression argument should have exactly 1 statement inside'
        ' of it, but has %d statements.' % len(stmt.body))
  return stmt.body[0]