Skip to content

Commit

Permalink
Simplify types
Browse files Browse the repository at this point in the history
  • Loading branch information
nazywam committed Mar 25, 2024
1 parent d207686 commit 3d058d6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions karton/core/karton.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from .task import Task, TaskState
from .utils import timeout

KartonTaskException = Union[Exception, BaseException]


class Producer(KartonBase):
"""
Expand Down Expand Up @@ -132,7 +134,7 @@ def __init__(
self._post_hooks: List[
Tuple[
Optional[str],
Callable[[Task, Optional[Union[Exception, BaseException]]], None],
Callable[[Task, Optional[KartonTaskException]], None],
]
] = []

Expand Down Expand Up @@ -264,7 +266,7 @@ def add_pre_hook(

def add_post_hook(
self,
callback: Callable[[Task, Optional[Exception]], None],
callback: Callable[[Task, Optional[KartonTaskException]], None],
name: Optional[str] = None,
) -> None:
"""
Expand Down Expand Up @@ -293,9 +295,7 @@ def _run_pre_hooks(self) -> None:
else:
self.log.exception("Pre-hook failed")

def _run_post_hooks(
self, exception: Optional[Union[Exception, BaseException]]
) -> None:
def _run_post_hooks(self, exception: Optional[KartonTaskException]) -> None:
"""
Run registered postprocessing hooks
Expand Down

0 comments on commit 3d058d6

Please sign in to comment.