Skip to content

Commit d3cd736

Browse files
committed
fix types for render
1 parent a9d0caf commit d3cd736

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

idom/core/render.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import abc
22
import asyncio
33
from functools import wraps
4-
from typing import Callable, Awaitable, Dict, Any, AsyncIterator
4+
from typing import Callable, Awaitable, Dict, Any, AsyncIterator, TypeVar, cast
55

66
from anyio import create_task_group, TaskGroup # type: ignore
77
from jsonpatch import make_patch, apply_patch
@@ -106,7 +106,7 @@ class SharedStateRenderer(SingleStateRenderer):
106106

107107
def __init__(self, layout: Layout) -> None:
108108
super().__init__(layout)
109-
self._model_state = {}
109+
self._model_state: Any = {}
110110
self._update_queues: Dict[str, asyncio.Queue[LayoutUpdate]] = {}
111111

112112
@async_resource
@@ -147,21 +147,24 @@ async def _join_event(self) -> AsyncIterator[asyncio.Event]:
147147
event.set()
148148

149149

150-
def _apply_layout_update(doc: Dict[str, Any], update: LayoutUpdate) -> Dict[str, Any]:
150+
def _apply_layout_update(doc: Dict[str, Any], update: LayoutUpdate) -> Any:
151151
return apply_patch(
152152
doc, [{**c, "path": update.path + c["path"]} for c in update.changes]
153153
)
154154

155155

156-
def _async_log_exceptions(function):
156+
_F = TypeVar("_F", bound=Callable[..., Any])
157+
158+
159+
def _async_log_exceptions(function: _F) -> _F:
157160
# BUG: https://github.com/agronholm/anyio/issues/155
158161

159162
@wraps(function)
160-
async def wrapper(*args, **kwargs):
163+
async def wrapper(*args: Any, **kwargs: Any) -> Any:
161164
try:
162165
return await function(*args, **kwargs)
163166
except Exception:
164167
logger.exception(f"Failure in {function}")
165168
raise
166169

167-
return wrapper
170+
return cast(_F, wrapper)

0 commit comments

Comments
 (0)