Skip to content

Commit 316184d

Browse files
Exported HookFunction typing to _types
1 parent 2381f10 commit 316184d

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/thread/_types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Documentation: https://thread.ngjx.org
55
"""
66

7-
from typing import Any, Literal
7+
from typing import Any, Literal, Callable, Union
88

99
ThreadStatus = Literal[
1010
'Idle',
@@ -19,3 +19,5 @@
1919
Data_In = Any
2020
Data_Out = Any
2121
Overflow_In = Any
22+
23+
HookFunction = Callable[[Data_Out], Union[Any, None]]

src/thread/thread.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ParallelProcessing: ...
1919
from .utils.config import Settings
2020
from .utils.algorithm import chunk_split
2121

22-
from ._types import ThreadStatus, Data_In, Data_Out, Overflow_In
22+
from ._types import ThreadStatus, Data_In, Data_Out, Overflow_In, HookFunction
2323
from typing import (
2424
Any, List,
2525
Callable, Union, Optional,
@@ -37,7 +37,7 @@ class Thread(threading.Thread):
3737
"""
3838

3939
status : ThreadStatus
40-
hooks : List[Callable[[Data_Out], Union[Any, None]]]
40+
hooks : List[HookFunction]
4141
returned_value: Data_Out
4242

4343
errors : List[Exception]
@@ -208,7 +208,7 @@ def is_alive(self) -> bool:
208208
return super().is_alive()
209209

210210

211-
def add_hook(self, hook: Callable[[Data_Out], Union[Any, None]]) -> None:
211+
def add_hook(self, hook: HookFunction) -> None:
212212
"""
213213
Adds a hook to the thread
214214
-------------------------

0 commit comments

Comments
 (0)