From 5db5477a5893a31f7c30752e4de58d4594ed1933 Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Mon, 4 Nov 2024 10:14:52 +0100 Subject: [PATCH] bla 2 --- rdfproxy/checks/checkers.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rdfproxy/checks/checkers.py b/rdfproxy/checks/checkers.py index b9ee080..3899a1b 100644 --- a/rdfproxy/checks/checkers.py +++ b/rdfproxy/checks/checkers.py @@ -8,13 +8,23 @@ check_select_query, check_solution_modifiers, ) -from toolz import compose_left T = TypeVar("T") _TCheck = Callable[[T], T | NoReturn] +def compose_left(*fns: Callable) -> Callable: + def _left_wrapper(*fns): + fn, *rest_fns = fns + + if rest_fns: + return lambda *args, **kwargs: fn(_left_wrapper(*rest_fns)(*args, **kwargs)) + return fn + + return _left_wrapper(*reversed(fns)) + + def compose_checker(*checkers: _TCheck) -> _TCheck: return compose_left(*checkers)