keep typing
This commit is contained in:
parent
21b0a034d6
commit
c90583d8e5
@ -964,7 +964,7 @@ class App(MiddlewareMixin, LifespanMixin):
|
||||
with executor:
|
||||
result_futures = []
|
||||
|
||||
def _submit_work(fn, *args, **kwargs):
|
||||
def _submit_work(fn: Callable, *args, **kwargs):
|
||||
f = executor.submit(fn, *args, **kwargs)
|
||||
# f = executor.apipe(fn, *args, **kwargs)
|
||||
result_futures.append(f)
|
||||
|
@ -404,7 +404,7 @@ class env_var: # type: ignore
|
||||
self.default = default
|
||||
self.internal = internal
|
||||
|
||||
def __set_name__(self, owner, name):
|
||||
def __set_name__(self, owner: Any, name: str):
|
||||
"""Set the name of the descriptor.
|
||||
|
||||
Args:
|
||||
@ -413,7 +413,7 @@ class env_var: # type: ignore
|
||||
"""
|
||||
self.name = name
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
def __get__(self, instance: Any, owner: Any):
|
||||
"""Get the EnvVar instance.
|
||||
|
||||
Args:
|
||||
@ -432,7 +432,7 @@ class env_var: # type: ignore
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
def env_var(default, internal=False) -> EnvVar:
|
||||
def env_var(default: Any, internal: bool = False) -> EnvVar:
|
||||
"""Typing helper for the env_var descriptor.
|
||||
|
||||
Args:
|
||||
|
@ -11,7 +11,7 @@ def _compose_react_imports(tags: list[str]) -> dict[str, list[ImportVar]]:
|
||||
return {"react": [ImportVar(tag=tag) for tag in tags]}
|
||||
|
||||
|
||||
def const(name, value) -> Var:
|
||||
def const(name: str | list[str], value: str | Var) -> Var:
|
||||
"""Create a constant Var.
|
||||
|
||||
Args:
|
||||
@ -26,7 +26,7 @@ def const(name, value) -> Var:
|
||||
return Var(_js_expr=f"const {name} = {value}")
|
||||
|
||||
|
||||
def useCallback(func, deps) -> Var:
|
||||
def useCallback(func: str, deps: list) -> Var:
|
||||
"""Create a useCallback hook with a function and dependencies.
|
||||
|
||||
Args:
|
||||
@ -42,7 +42,7 @@ def useCallback(func, deps) -> Var:
|
||||
)
|
||||
|
||||
|
||||
def useContext(context) -> Var:
|
||||
def useContext(context: str) -> Var:
|
||||
"""Create a useContext hook with a context.
|
||||
|
||||
Args:
|
||||
@ -57,7 +57,7 @@ def useContext(context) -> Var:
|
||||
)
|
||||
|
||||
|
||||
def useRef(default) -> Var:
|
||||
def useRef(default: str) -> Var:
|
||||
"""Create a useRef hook with a default value.
|
||||
|
||||
Args:
|
||||
@ -72,7 +72,7 @@ def useRef(default) -> Var:
|
||||
)
|
||||
|
||||
|
||||
def useState(var_name, default=None) -> Var:
|
||||
def useState(var_name: str, default: str | None = None) -> Var:
|
||||
"""Create a useState hook with a variable name and setter name.
|
||||
|
||||
Args:
|
||||
|
@ -1,16 +1,16 @@
|
||||
"""Miscellaneous functions for the experimental package."""
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
from typing import Any, Callable
|
||||
|
||||
|
||||
async def run_in_thread(func) -> Any:
|
||||
async def run_in_thread(func: Callable) -> Any:
|
||||
"""Run a function in a separate thread.
|
||||
|
||||
To not block the UI event queue, run_in_thread must be inside inside a rx.event(background=True) decorated method.
|
||||
|
||||
Args:
|
||||
func (callable): The non-async function to run.
|
||||
func: The non-async function to run.
|
||||
|
||||
Raises:
|
||||
ValueError: If the function is an async function.
|
||||
|
Loading…
Reference in New Issue
Block a user