def _lambda_repr()

in chz/blueprint/_blueprint.py [0:0]


def _lambda_repr(fn) -> str | None:
    try:
        src = inspect.getsource(fn).strip()
        tree = ast.parse(src)
        nodes = [node for node in ast.walk(tree) if isinstance(node, ast.Lambda)]
        if len(nodes) != 1:
            return None
        return ast.unparse(nodes[0])
    except Exception:
        return None