import ast


def maybe_get_docstring(node: ast.AST):
    """Get docstring from a constant expression, or return None."""
    if (
        isinstance(node, ast.Expr)
        and isinstance(node.value, ast.Constant)
        and isinstance(node.value.value, str)
    ):
        return node.value.value
    elif (
        isinstance(node, ast.Expr)
        and isinstance(node.value, ast.Str)
    ):
        return node.value.s