11"""
22## Processor
33
4- Documentation: https://thread.ngjx.org/docs/v1.0 .0
4+ Documentation: https://thread.ngjx.org/docs/v1.1 .0
55"""
66
77from functools import wraps
88from ..thread import ParallelProcessing
99
10- from .._types import Overflow_In , Data_In
11- from typing import Callable , Mapping , Sequence , Optional , Union , overload
10+ from .._types import (
11+ Overflow_In ,
12+ Data_In ,
13+ SupportsGetItem ,
14+ SupportsLength ,
15+ SupportsLengthGetItem ,
16+ )
17+ from typing import Any , Callable , Mapping , Sequence , Optional , Union , overload
1218from typing_extensions import ParamSpec , TypeVar , Concatenate
1319
1420
1521_TargetT = TypeVar ('_TargetT' )
1622_TargetP = ParamSpec ('_TargetP' )
1723_DataT = TypeVar ('_DataT' )
1824TargetFunction = Callable [Concatenate [_DataT , _TargetP ], _TargetT ]
25+ Dataset = Union [
26+ SupportsLengthGetItem [_DataT ], SupportsGetItem [_DataT ], SupportsLength , Any
27+ ]
1928
2029
2130NoParamReturn = Callable [
22- Concatenate [Sequence [_DataT ], _TargetP ],
31+ Concatenate [Dataset [_DataT ], _TargetP ],
2332 ParallelProcessing [_TargetP , _TargetT , _DataT ],
2433]
2534WithParamReturn = Callable [
2635 [TargetFunction [_DataT , _TargetP , _TargetT ]],
2736 NoParamReturn [_DataT , _TargetP , _TargetT ],
2837]
2938FullParamReturn = Callable [
30- Concatenate [Sequence [_DataT ], _TargetP ],
39+ Concatenate [Dataset [_DataT ], _TargetP ],
3140 ParallelProcessing [_TargetP , _TargetT , _DataT ],
3241]
3342
3443
3544@overload
3645def processor (
3746 __function : TargetFunction [_DataT , _TargetP , _TargetT ],
38- ) -> NoParamReturn [_DataT , _TargetP , _TargetT ]:
39- ...
47+ ) -> NoParamReturn [_DataT , _TargetP , _TargetT ]: ...
4048
4149
4250@overload
@@ -47,8 +55,7 @@ def processor(
4755 ignore_errors : Sequence [type [Exception ]] = (),
4856 suppress_errors : bool = False ,
4957 ** overflow_kwargs : Overflow_In ,
50- ) -> WithParamReturn [_DataT , _TargetP , _TargetT ]:
51- ...
58+ ) -> WithParamReturn [_DataT , _TargetP , _TargetT ]: ...
5259
5360
5461@overload
@@ -60,8 +67,7 @@ def processor(
6067 ignore_errors : Sequence [type [Exception ]] = (),
6168 suppress_errors : bool = False ,
6269 ** overflow_kwargs : Overflow_In ,
63- ) -> FullParamReturn [_DataT , _TargetP , _TargetT ]:
64- ...
70+ ) -> FullParamReturn [_DataT , _TargetP , _TargetT ]: ...
6571
6672
6773def processor (
@@ -106,8 +112,7 @@ def processor(
106112
107113 You can also pass keyword arguments to change the thread behaviour, it otherwise follows the defaults of `thread.Thread`
108114 >>> @thread.threaded(daemon = True)
109- >>> def myfunction():
110- ... ...
115+ >>> def myfunction(): ...
111116
112117 Args will be ordered infront of function-parsed args parsed into `thread.Thread.args`
113118 >>> @thread.threaded(args = (1))
@@ -142,7 +147,7 @@ def wrapper(
142147
143148 @wraps (__function )
144149 def wrapped (
145- data : Sequence [_DataT ],
150+ data : Dataset [_DataT ],
146151 * parsed_args : _TargetP .args ,
147152 ** parsed_kwargs : _TargetP .kwargs ,
148153 ) -> ParallelProcessing [_TargetP , _TargetT , _DataT ]:
0 commit comments