From c90583d8e52010ff4105661fe66c405c420121e0 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Wed, 20 Nov 2024 20:48:05 +0100 Subject: [PATCH] keep typing --- reflex/app.py | 2 +- reflex/config.py | 6 +++--- reflex/experimental/hooks.py | 10 +++++----- reflex/experimental/misc.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/reflex/app.py b/reflex/app.py index 0282352e9..02e4a676a 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -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) diff --git a/reflex/config.py b/reflex/config.py index 049cc2e83..2f9868046 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -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: diff --git a/reflex/experimental/hooks.py b/reflex/experimental/hooks.py index 7d648225a..fb2dc8cae 100644 --- a/reflex/experimental/hooks.py +++ b/reflex/experimental/hooks.py @@ -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: diff --git a/reflex/experimental/misc.py b/reflex/experimental/misc.py index a2a5a0615..986729881 100644 --- a/reflex/experimental/misc.py +++ b/reflex/experimental/misc.py @@ -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.