misc typing
This commit is contained in:
parent
dd9a8d8ef7
commit
d5d70c61ff
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections import defaultdict
|
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.config import get_config
|
||||||
from reflex.event import BASE_STATE, EventType
|
from reflex.event import BASE_STATE, EventType
|
||||||
@ -42,7 +42,7 @@ def page(
|
|||||||
The decorated function.
|
The decorated function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(render_fn):
|
def decorator(render_fn: Callable):
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if route:
|
if route:
|
||||||
kwargs["route"] = route
|
kwargs["route"] = route
|
||||||
@ -66,7 +66,7 @@ def page(
|
|||||||
return decorator
|
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.
|
"""Get the decorated pages.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -103,7 +103,7 @@ def catchall_prefix(route: str) -> str:
|
|||||||
return route.replace(pattern, "") if pattern else ""
|
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.
|
"""Replace brackets and everything inside it in a string with a keyword.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -185,7 +185,9 @@ def convert(
|
|||||||
var_data = None # Track import/hook data from any Vars in the style dict.
|
var_data = None # Track import/hook data from any Vars in the style dict.
|
||||||
out = {}
|
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:
|
for k in keys_to_update:
|
||||||
out[k] = return_value
|
out[k] = return_value
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ else:
|
|||||||
class chdir(contextlib.AbstractContextManager):
|
class chdir(contextlib.AbstractContextManager):
|
||||||
"""Non thread-safe context manager to change the current working directory."""
|
"""Non thread-safe context manager to change the current working directory."""
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path: str | pathlib.Path):
|
||||||
"""Prepare contextmanager.
|
"""Prepare contextmanager.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -321,7 +321,7 @@ class AppHarness:
|
|||||||
|
|
||||||
return _shutdown_redis
|
return _shutdown_redis
|
||||||
|
|
||||||
def _start_backend(self, port=0):
|
def _start_backend(self, port: int = 0):
|
||||||
if self.app_instance is None:
|
if self.app_instance is None:
|
||||||
raise RuntimeError("App was not initialized.")
|
raise RuntimeError("App was not initialized.")
|
||||||
self.backend = uvicorn.Server(
|
self.backend = uvicorn.Server(
|
||||||
@ -425,7 +425,7 @@ class AppHarness:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
@staticmethod
|
@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.
|
"""Get the source code of a global object.
|
||||||
If value is a function or class we render the actual
|
If value is a function or class we render the actual
|
||||||
source of value otherwise we assign value to key.
|
source of value otherwise we assign value to key.
|
||||||
|
Loading…
Reference in New Issue
Block a user