17
17
18
18
from redux .basic_types import (
19
19
Action ,
20
- AutorunArgs ,
20
+ Args ,
21
21
AutorunOptions ,
22
- AutorunOriginalReturnType ,
23
22
ComparatorOutput ,
24
23
Event ,
24
+ ReturnType ,
25
25
SelectorOutput ,
26
26
State ,
27
27
)
@@ -58,8 +58,8 @@ class Autorun(
58
58
Event ,
59
59
SelectorOutput ,
60
60
ComparatorOutput ,
61
- AutorunOriginalReturnType ,
62
- AutorunArgs ,
61
+ ReturnType ,
62
+ Args ,
63
63
],
64
64
):
65
65
def __init__ (
@@ -69,10 +69,10 @@ def __init__(
69
69
selector : Callable [[State ], SelectorOutput ],
70
70
comparator : Callable [[State ], Any ] | None ,
71
71
func : Callable [
72
- Concatenate [SelectorOutput , AutorunArgs ],
73
- AutorunOriginalReturnType ,
72
+ Concatenate [SelectorOutput , Args ],
73
+ ReturnType ,
74
74
],
75
- options : AutorunOptions [AutorunOriginalReturnType ],
75
+ options : AutorunOptions [ReturnType ],
76
76
) -> None :
77
77
self .__name__ = func .__name__
78
78
self ._store = store
@@ -109,10 +109,9 @@ def __init__(
109
109
self ._latest_value = Future ()
110
110
self ._latest_value .set_result (options .default_value )
111
111
else :
112
- self ._latest_value : AutorunOriginalReturnType = options .default_value
112
+ self ._latest_value : ReturnType = options .default_value
113
113
self ._subscriptions : set [
114
- Callable [[AutorunOriginalReturnType ], Any ]
115
- | weakref .ref [Callable [[AutorunOriginalReturnType ], Any ]]
114
+ Callable [[ReturnType ], Any ] | weakref .ref [Callable [[ReturnType ], Any ]]
116
115
] = set ()
117
116
118
117
if self ._check (store ._state ) and self ._options .initial_call : # noqa: SLF001
@@ -137,8 +136,8 @@ def inform_subscribers(
137
136
Event ,
138
137
SelectorOutput ,
139
138
ComparatorOutput ,
140
- AutorunOriginalReturnType ,
141
- AutorunArgs ,
139
+ ReturnType ,
140
+ Args ,
142
141
],
143
142
) -> None :
144
143
for subscriber_ in self ._subscriptions .copy ():
@@ -158,8 +157,8 @@ def _task_callback(
158
157
Event ,
159
158
SelectorOutput ,
160
159
ComparatorOutput ,
161
- AutorunOriginalReturnType ,
162
- AutorunArgs ,
160
+ ReturnType ,
161
+ Args ,
163
162
],
164
163
task : Task ,
165
164
* ,
@@ -179,8 +178,8 @@ def _check(
179
178
Event ,
180
179
SelectorOutput ,
181
180
ComparatorOutput ,
182
- AutorunOriginalReturnType ,
183
- AutorunArgs ,
181
+ ReturnType ,
182
+ Args ,
184
183
],
185
184
state : State | None ,
186
185
) -> bool :
@@ -211,16 +210,16 @@ def _call(
211
210
Event ,
212
211
SelectorOutput ,
213
212
ComparatorOutput ,
214
- AutorunOriginalReturnType ,
215
- AutorunArgs ,
213
+ ReturnType ,
214
+ Args ,
216
215
],
217
- * args : AutorunArgs .args ,
218
- ** kwargs : AutorunArgs .kwargs ,
216
+ * args : Args .args ,
217
+ ** kwargs : Args .kwargs ,
219
218
) -> None :
220
219
self ._should_be_called = False
221
220
func = self ._func () if isinstance (self ._func , weakref .ref ) else self ._func
222
221
if func and self ._last_selector_result is not None :
223
- value : AutorunOriginalReturnType = func (
222
+ value : ReturnType = func (
224
223
self ._last_selector_result ,
225
224
* args ,
226
225
** kwargs ,
@@ -229,7 +228,7 @@ def _call(
229
228
if iscoroutine (value ) and create_task :
230
229
if self ._options .auto_await :
231
230
future = Future ()
232
- self ._latest_value = cast (AutorunOriginalReturnType , future )
231
+ self ._latest_value = cast (ReturnType , future )
233
232
create_task (
234
233
value ,
235
234
callback = functools .partial (
@@ -245,7 +244,7 @@ def _call(
245
244
):
246
245
self ._latest_value .close ()
247
246
self ._latest_value = cast (
248
- AutorunOriginalReturnType ,
247
+ ReturnType ,
249
248
AwaitableWrapper (value ),
250
249
)
251
250
else :
@@ -259,17 +258,17 @@ def __call__(
259
258
Event ,
260
259
SelectorOutput ,
261
260
ComparatorOutput ,
262
- AutorunOriginalReturnType ,
263
- AutorunArgs ,
261
+ ReturnType ,
262
+ Args ,
264
263
],
265
- * args : AutorunArgs .args ,
266
- ** kwargs : AutorunArgs .kwargs ,
267
- ) -> AutorunOriginalReturnType :
264
+ * args : Args .args ,
265
+ ** kwargs : Args .kwargs ,
266
+ ) -> ReturnType :
268
267
state = self ._store ._state # noqa: SLF001
269
268
self ._check (state )
270
269
if self ._should_be_called or args or kwargs or not self ._options .memoization :
271
270
self ._call (* args , ** kwargs )
272
- return cast (AutorunOriginalReturnType , self ._latest_value )
271
+ return cast (ReturnType , self ._latest_value )
273
272
274
273
def __repr__ (
275
274
self : Autorun [
@@ -278,8 +277,8 @@ def __repr__(
278
277
Event ,
279
278
SelectorOutput ,
280
279
ComparatorOutput ,
281
- AutorunOriginalReturnType ,
282
- AutorunArgs ,
280
+ ReturnType ,
281
+ Args ,
283
282
],
284
283
) -> str :
285
284
return (
@@ -295,11 +294,11 @@ def value(
295
294
Event ,
296
295
SelectorOutput ,
297
296
ComparatorOutput ,
298
- AutorunOriginalReturnType ,
299
- AutorunArgs ,
297
+ ReturnType ,
298
+ Args ,
300
299
],
301
- ) -> AutorunOriginalReturnType :
302
- return cast (AutorunOriginalReturnType , self ._latest_value )
300
+ ) -> ReturnType :
301
+ return cast (ReturnType , self ._latest_value )
303
302
304
303
def subscribe (
305
304
self : Autorun [
@@ -308,10 +307,10 @@ def subscribe(
308
307
Event ,
309
308
SelectorOutput ,
310
309
ComparatorOutput ,
311
- AutorunOriginalReturnType ,
312
- AutorunArgs ,
310
+ ReturnType ,
311
+ Args ,
313
312
],
314
- callback : Callable [[AutorunOriginalReturnType ], Any ],
313
+ callback : Callable [[ReturnType ], Any ],
315
314
* ,
316
315
initial_run : bool | None = None ,
317
316
keep_ref : bool | None = None ,
@@ -344,8 +343,8 @@ def __signature__(
344
343
Event ,
345
344
SelectorOutput ,
346
345
ComparatorOutput ,
347
- AutorunOriginalReturnType ,
348
- AutorunArgs ,
346
+ ReturnType ,
347
+ Args ,
349
348
],
350
349
) -> inspect .Signature :
351
350
return self ._signature
0 commit comments