executor#
Collect PrecommitError instances from several executed functions.
- class Executor(raise_exception: bool = True)[source]#
Bases:
AbstractContextManagerExecute functions and collect any
PrecommitErrorexceptions.The collected exceptions are merged and re-raised as a single
PrecommitErrorwhen the context manager exits. Setraise_exception=Falseto print the collected messages instead of raising.>>> def function1() -> None: ... raise PrecommitError("Error message 1") >>> def function2() -> None: ... raise PrecommitError("Error message 2") >>> def function3() -> None: ... >>> >>> with Executor(raise_exception=False) as execute: ... execute(function1) ... execute(function2) ... execute(function3) Error message 1 -------------------- Error message 2