Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d4e6abe

Browse files
committedJun 21, 2024·
fix type hints
1 parent 62579bd commit d4e6abe

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed
 

‎src/reactpy_django/pyscript/layout_handler.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# mypy: disable-error-code=attr-defined
12
import asyncio
2-
from typing import Coroutine
3+
from typing import Callable
34

45
import js
56
from jsonpointer import set_pointer
67
from pyodide.ffi.wrappers import add_event_listener
78
from reactpy.core.layout import Layout
9+
from reactpy.types import ComponentType
810

911

1012
class ReactPyLayoutHandler:
@@ -100,9 +102,9 @@ def delete_old_workspaces():
100102
f"Warning: Could not auto delete PyScript workspace {workspace_name}"
101103
)
102104

103-
async def run(self, workspace_function: Coroutine):
105+
async def run(self, workspace_function: Callable[[], ComponentType]):
104106
self.delete_old_workspaces()
105-
root_model = {}
107+
root_model: dict = {}
106108

107109
async with Layout(workspace_function()) as layout:
108110
while True:

‎src/reactpy_django/utils.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from fnmatch import fnmatch
1212
from importlib import import_module
1313
from pathlib import Path
14-
from typing import Any, Callable, Sequence
14+
from typing import Any, Callable, Mapping, Sequence
1515
from uuid import UUID, uuid4
1616

1717
import jsonpointer
@@ -407,7 +407,11 @@ def strtobool(val):
407407

408408

409409
def prerender_component(
410-
user_component: ComponentConstructor, args, kwargs, uuid, request: HttpRequest
410+
user_component: ComponentConstructor,
411+
args: Sequence,
412+
kwargs: Mapping,
413+
uuid: str | UUID,
414+
request: HttpRequest,
411415
) -> str:
412416
"""Prerenders a ReactPy component and returns the HTML string."""
413417
search = request.GET.urlencode()
@@ -432,12 +436,12 @@ def prerender_component(
432436

433437

434438
def vdom_or_component_to_string(
435-
vdom_or_component: Any, request: HttpRequest | None = None, uuid: UUID | None = None
439+
vdom_or_component: Any, request: HttpRequest | None = None, uuid: str | None = None
436440
) -> str:
437441
"""Converts a VdomDict or component to an HTML string. If a string is provided instead, it will be
438442
automatically returned."""
439443
if isinstance(vdom_or_component, dict):
440-
return vdom_to_html(vdom_or_component)
444+
return vdom_to_html(vdom_or_component) # type: ignore
441445

442446
if hasattr(vdom_or_component, "render"):
443447
if not request:

0 commit comments

Comments
 (0)
Please sign in to comment.