diff --git a/reflex/page.py b/reflex/page.py index 8cc031757..06eadb184 100644 --- a/reflex/page.py +++ b/reflex/page.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections import defaultdict -from typing import Any, Dict, List +from typing import Any, Callable, Dict, List from reflex.config import get_config from reflex.event import BASE_STATE, EventType @@ -42,7 +42,7 @@ def page( The decorated function. """ - def decorator(render_fn): + def decorator(render_fn: Callable): kwargs = {} if route: kwargs["route"] = route @@ -66,7 +66,7 @@ def page( return decorator -def get_decorated_pages(omit_implicit_routes=True) -> list[dict[str, Any]]: +def get_decorated_pages(omit_implicit_routes: bool = True) -> list[dict[str, Any]]: """Get the decorated pages. Args: diff --git a/reflex/route.py b/reflex/route.py index 0b7172824..3f49f66e9 100644 --- a/reflex/route.py +++ b/reflex/route.py @@ -103,7 +103,7 @@ def catchall_prefix(route: str) -> str: return route.replace(pattern, "") if pattern else "" -def replace_brackets_with_keywords(input_string): +def replace_brackets_with_keywords(input_string: str) -> str: """Replace brackets and everything inside it in a string with a keyword. Args: diff --git a/reflex/style.py b/reflex/style.py index f0ee8c6a7..f2923fa38 100644 --- a/reflex/style.py +++ b/reflex/style.py @@ -185,7 +185,9 @@ def convert( var_data = None # Track import/hook data from any Vars in the style dict. out = {} - def update_out_dict(return_value, keys_to_update): + def update_out_dict( + return_value: Var | dict | list | str, keys_to_update: tuple[str, ...] + ): for k in keys_to_update: out[k] = return_value diff --git a/reflex/testing.py b/reflex/testing.py index 9ddb03504..a7f3f73a8 100644 --- a/reflex/testing.py +++ b/reflex/testing.py @@ -89,7 +89,7 @@ else: class chdir(contextlib.AbstractContextManager): """Non thread-safe context manager to change the current working directory.""" - def __init__(self, path): + def __init__(self, path: str | pathlib.Path): """Prepare contextmanager. Args: @@ -321,7 +321,7 @@ class AppHarness: return _shutdown_redis - def _start_backend(self, port=0): + def _start_backend(self, port: int = 0): if self.app_instance is None: raise RuntimeError("App was not initialized.") self.backend = uvicorn.Server( @@ -425,7 +425,7 @@ class AppHarness: return self @staticmethod - def get_app_global_source(key, value): + def get_app_global_source(key: str, value: Any): """Get the source code of a global object. If value is a function or class we render the actual source of value otherwise we assign value to key.