misc typing
This commit is contained in:
parent
dd9a8d8ef7
commit
d5d70c61ff
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user