1515T = TypeVar ('T' )
1616P = ParamSpec ('P' )
1717TargetFunction = Callable [P , Data_Out ]
18- NoParamReturn = Callable [P , Thread ]
19- WithParamReturn = Callable [[TargetFunction ] , NoParamReturn ]
18+ NoParamReturn = Callable [P , Thread [ P , T ] ]
19+ WithParamReturn = Callable [[TargetFunction [ P ]] , NoParamReturn [ P , T ] ]
2020FullParamReturn = Callable [P , Thread ]
21- WrappedWithParamReturn = Callable [[TargetFunction ] , WithParamReturn ]
21+ WrappedWithParamReturn = Callable [[TargetFunction [ P ]] , WithParamReturn [ P , T ] ]
2222
2323
2424@overload
25- def threaded (__function : TargetFunction ) -> NoParamReturn : ...
25+ def threaded (__function : TargetFunction [ P ] ) -> NoParamReturn [ P , T ] : ...
2626
2727@overload
2828def threaded (
@@ -32,7 +32,7 @@ def threaded(
3232 ignore_errors : Sequence [type [Exception ]] = (),
3333 suppress_errors : bool = False ,
3434 ** overflow_kwargs : Overflow_In
35- ) -> WithParamReturn : ...
35+ ) -> WithParamReturn [ P , T ] : ...
3636
3737@overload
3838def threaded (
@@ -43,18 +43,18 @@ def threaded(
4343 ignore_errors : Sequence [type [Exception ]] = (),
4444 suppress_errors : bool = False ,
4545 ** overflow_kwargs : Overflow_In
46- ) -> FullParamReturn : ...
46+ ) -> FullParamReturn [ P ] : ...
4747
4848
4949def threaded (
50- __function : Optional [TargetFunction ] = None ,
50+ __function : Optional [TargetFunction [ P ] ] = None ,
5151 * ,
5252 args : Sequence [Data_In ] = (),
5353 kwargs : Mapping [str , Data_In ] = {},
5454 ignore_errors : Sequence [type [Exception ]] = (),
5555 suppress_errors : bool = False ,
5656 ** overflow_kwargs : Overflow_In
57- ) -> Union [NoParamReturn , WithParamReturn , FullParamReturn ]:
57+ ) -> Union [NoParamReturn [ P , T ], WithParamReturn [ P , T ], FullParamReturn [ P ] ]:
5858 """
5959 Decorate a function to run it in a thread
6060
@@ -96,7 +96,7 @@ def threaded(
9696 """
9797
9898 if not callable (__function ):
99- def wrapper (func : TargetFunction ) -> FullParamReturn :
99+ def wrapper (func : TargetFunction [ P ] ) -> FullParamReturn [ P ] :
100100 return threaded (
101101 func ,
102102 args = args ,
0 commit comments