99 Any ,
1010 Concatenate ,
1111 Generic ,
12- Never ,
12+ Literal ,
1313 ParamSpec ,
1414 Protocol ,
1515 TypeAlias ,
1616 TypeGuard ,
17+ cast ,
1718 overload ,
1819)
1920
@@ -144,10 +145,75 @@ class StoreOptions(Immutable, Generic[Action, Event]):
144145
145146# Autorun
146147
148+ AutoAwait = TypeVar ('AutoAwait' , bound = Literal [True , False , None ], infer_variance = True )
147149
148- class AutorunOptions (Immutable , Generic [ReturnType ]):
150+
151+ class AutorunOptionsType (Immutable , Generic [ReturnType , AutoAwait ]):
152+ default_value : ReturnType | None = None
153+ auto_await : AutoAwait = cast ('AutoAwait' , val = None )
154+ initial_call : bool = True
155+ reactive : bool = True
156+ memoization : bool = True
157+ keep_ref : bool = True
158+ subscribers_initial_run : bool = True
159+ subscribers_keep_ref : bool = True
160+
161+ @overload
162+ def __init__ (
163+ self : AutorunOptionsType [ReturnType , Literal [None ]], # type: ignore[reportInvalidTypeVar]
164+ * ,
165+ default_value : ReturnType | None = None ,
166+ auto_await : Literal [None ] | None = None ,
167+ initial_call : bool = True ,
168+ reactive : bool = True ,
169+ memoization : bool = True ,
170+ keep_ref : bool = True ,
171+ subscribers_initial_run : bool = True ,
172+ subscribers_keep_ref : bool = True ,
173+ ) -> None : ...
174+ @overload
175+ def __init__ (
176+ self : AutorunOptionsType [ReturnType , Literal [True ]], # type: ignore[reportInvalidTypeVar]
177+ * ,
178+ default_value : ReturnType | None = None ,
179+ auto_await : Literal [True ],
180+ initial_call : bool = True ,
181+ reactive : bool = True ,
182+ memoization : bool = True ,
183+ keep_ref : bool = True ,
184+ subscribers_initial_run : bool = True ,
185+ subscribers_keep_ref : bool = True ,
186+ ) -> None : ...
187+ @overload
188+ def __init__ (
189+ self : AutorunOptionsType [ReturnType , Literal [False ]], # type: ignore[reportInvalidTypeVar]
190+ * ,
191+ default_value : ReturnType | None = None ,
192+ auto_await : Literal [False ],
193+ initial_call : bool = True ,
194+ reactive : bool = True ,
195+ memoization : bool = True ,
196+ keep_ref : bool = True ,
197+ subscribers_initial_run : bool = True ,
198+ subscribers_keep_ref : bool = True ,
199+ ) -> None : ...
200+ def __init__ ( # noqa: PLR0913
201+ self : AutorunOptionsType ,
202+ * ,
203+ default_value : ReturnType | None = None ,
204+ auto_await : bool | None = None ,
205+ initial_call : bool = True ,
206+ reactive : bool = True ,
207+ memoization : bool = True ,
208+ keep_ref : bool = True ,
209+ subscribers_initial_run : bool = True ,
210+ subscribers_keep_ref : bool = True ,
211+ ) -> None : ...
212+
213+
214+ class AutorunOptionsImplementation (Immutable , Generic [ReturnType , AutoAwait ]):
149215 default_value : ReturnType | None = None
150- auto_await : bool = True
216+ auto_await : AutoAwait = cast ( 'AutoAwait' , val = None )
151217 initial_call : bool = True
152218 reactive : bool = True
153219 memoization : bool = True
@@ -156,8 +222,7 @@ class AutorunOptions(Immutable, Generic[ReturnType]):
156222 subscribers_keep_ref : bool = True
157223
158224
159- AutorunOptionsWithDefault = AutorunOptions [ReturnType ]
160- AutorunOptionsWithoutDefault = AutorunOptions [Never ]
225+ AutorunOptions = cast ('type[AutorunOptionsType]' , AutorunOptionsImplementation )
161226
162227
163228class AutorunReturnType (
@@ -186,34 +251,39 @@ def unsubscribe(self: AutorunReturnType) -> None: ...
186251 __name__ : str
187252
188253
189- class AutorunDecorator (Protocol , Generic [SelectorOutput , ReturnType ]):
254+ class AutorunDecorator (Protocol , Generic [ReturnType , SelectorOutput , AutoAwait ]):
190255 @overload
191256 def __call__ (
192- self : AutorunDecorator ,
257+ self : AutorunDecorator [ReturnType , SelectorOutput , Literal [None ]],
258+ func : Callable [
259+ Concatenate [SelectorOutput , Args ],
260+ Awaitable [ReturnType ],
261+ ],
262+ ) -> AutorunReturnType [None , Args ]: ...
263+ @overload
264+ def __call__ (
265+ self : AutorunDecorator [ReturnType , SelectorOutput , Literal [None ]],
193266 func : Callable [
194267 Concatenate [SelectorOutput , Args ],
195268 ReturnType ,
196269 ],
197270 ) -> AutorunReturnType [ReturnType , Args ]: ...
198-
199271 @overload
200272 def __call__ (
201- self : AutorunDecorator ,
273+ self : AutorunDecorator [ ReturnType , SelectorOutput , Literal [ True ]] ,
202274 func : Callable [
203275 Concatenate [SelectorOutput , Args ],
204276 Awaitable [ReturnType ],
205277 ],
206- ) -> AutorunReturnType [Awaitable [ReturnType ], Args ]: ...
207-
208-
209- class UnknownAutorunDecorator (Protocol , Generic [SelectorOutput ]):
278+ ) -> AutorunReturnType [None , Args ]: ...
279+ @overload
210280 def __call__ (
211- self : UnknownAutorunDecorator ,
281+ self : AutorunDecorator [ ReturnType , SelectorOutput , Literal [ False ]] ,
212282 func : Callable [
213283 Concatenate [SelectorOutput , Args ],
214- ReturnType ,
284+ Awaitable [ ReturnType ] ,
215285 ],
216- ) -> AutorunReturnType [ReturnType , Args ]: ...
286+ ) -> AutorunReturnType [Awaitable [ ReturnType ] , Args ]: ...
217287
218288
219289# View
@@ -227,10 +297,6 @@ class ViewOptions(Immutable, Generic[ReturnType]):
227297 subscribers_keep_ref : bool = True
228298
229299
230- ViewOptionsWithDefault = ViewOptions [ReturnType ]
231- ViewOptionsWithoutDefault = ViewOptions [Never ]
232-
233-
234300class ViewReturnType (
235301 Protocol ,
236302 Generic [ReturnType , Args ],
@@ -257,17 +323,8 @@ def unsubscribe(self: ViewReturnType) -> None: ...
257323
258324class ViewDecorator (
259325 Protocol ,
260- Generic [SelectorOutput , ReturnType ],
326+ Generic [ReturnType , SelectorOutput ],
261327):
262- @overload
263- def __call__ (
264- self : ViewDecorator ,
265- func : Callable [
266- Concatenate [SelectorOutput , Args ],
267- ReturnType ,
268- ],
269- ) -> ViewReturnType [ReturnType , Args ]: ...
270-
271328 @overload
272329 def __call__ (
273330 self : ViewDecorator ,
@@ -277,10 +334,9 @@ def __call__(
277334 ],
278335 ) -> ViewReturnType [Awaitable [ReturnType ], Args ]: ...
279336
280-
281- class UnknownViewDecorator (Protocol , Generic [SelectorOutput ]):
337+ @overload
282338 def __call__ (
283- self : UnknownViewDecorator ,
339+ self : ViewDecorator ,
284340 func : Callable [
285341 Concatenate [SelectorOutput , Args ],
286342 ReturnType ,
0 commit comments