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