Skip to content

Commit 821dd55

Browse files
committed
fix misc types
1 parent d3cd736 commit 821dd55

File tree

3 files changed

+9
-40
lines changed

3 files changed

+9
-40
lines changed

idom/core/element.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ElementRenderFunction = Callable[..., Awaitable["VdomDict"]]
1414

1515

16-
def element(function: ElementRenderFunction) -> Callable[..., Any]:
16+
def element(function: ElementRenderFunction) -> Callable[..., "Element"]:
1717
"""A decorator for defining an :class:`Element`.
1818
1919
Parameters:

idom/core/hooks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def use_effect(
9696

9797

9898
@overload
99-
def use_effect(function: _EffectApplyFunc, args: Optional[Sequence[Any]]) -> None:
99+
def use_effect(
100+
function: _EffectApplyFunc, args: Optional[Sequence[Any]] = None
101+
) -> None:
100102
...
101103

102104

@@ -179,7 +181,7 @@ def use_callback(
179181

180182
@overload
181183
def use_callback(
182-
function: _CallbackFunc, args: Optional[Sequence[Any]]
184+
function: _CallbackFunc, args: Optional[Sequence[Any]] = None
183185
) -> _CallbackFunc:
184186
...
185187

@@ -224,7 +226,7 @@ def use_memo(
224226

225227
@overload
226228
def use_memo(
227-
function: Callable[[], _StateType], args: Optional[Sequence[Any]]
229+
function: Callable[[], _StateType], args: Optional[Sequence[Any]] = None
228230
) -> _StateType:
229231
...
230232

idom/widgets/utils.py

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pathlib import Path
2-
from typing import Any, Callable, Tuple, Optional, Dict, Union, Set
2+
from typing import Any, Callable, Tuple, Optional, Dict, Union, Set, cast
33

44
from typing_extensions import Protocol
55

@@ -183,7 +183,7 @@ async def HotSwap() -> Any:
183183
# new displays will adopt the latest constructor and arguments
184184
(f, a, kw), set_state = hooks.use_state(constructor_and_arguments.current)
185185

186-
def add_callback():
186+
def add_callback() -> Callable[[], None]:
187187
set_state_callbacks.add(set_state)
188188
return lambda: set_state_callbacks.remove(set_state)
189189

@@ -210,7 +210,7 @@ def swap(_func_: ElementConstructor, *args: Any, **kwargs: Any) -> None:
210210
constructor_and_arguments.current = (_func_, args, kwargs)
211211
return None
212212

213-
return swap, HotSwap
213+
return cast(MountFunc, swap), HotSwap
214214

215215

216216
def multiview() -> Tuple["MultiViewMount", ElementConstructor]:
@@ -290,36 +290,3 @@ def _add_view(
290290
kwargs: Dict[str, Any],
291291
) -> None:
292292
self._views[view_id] = lambda: constructor(*args, **kwargs)
293-
294-
295-
{
296-
"tagName": "div",
297-
"children": [
298-
{
299-
"tagName": "div",
300-
"children": [
301-
{
302-
"tagName": "button",
303-
"attributes": {"id": "incr-button"},
304-
"children": ["click to increment"],
305-
"eventHandlers": {
306-
"onClick": {
307-
"target": "139775953392160",
308-
"preventDefault": False,
309-
"stopPropagation": False,
310-
}
311-
},
312-
},
313-
{
314-
"tagName": "div",
315-
"attributes": {"id": "count-is-1"},
316-
"children": ["1"],
317-
},
318-
],
319-
}
320-
],
321-
}
322-
[
323-
{"path": "/children/1/attributes/id", "op": "replace", "value": "count-is-1"},
324-
{"path": "/children/1/children/0", "op": "replace", "value": "1"},
325-
]

0 commit comments

Comments
 (0)