diff --git a/nicegui/element.py b/nicegui/element.py index 806fcdcf9..c01a1982a 100644 --- a/nicegui/element.py +++ b/nicegui/element.py @@ -4,14 +4,14 @@ import re from copy import copy, deepcopy from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Union +from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Sequence, Union from typing_extensions import Self from nicegui import json from . import binding, events, globals, outbox, storage # pylint: disable=redefined-builtin -from .dependencies import JsComponent, Library, register_library, register_vue_component +from .dependencies import Component, Library, register_library, register_vue_component from .elements.mixins.visibility import Visibility from .event_listener import EventListener from .slot import Slot @@ -24,7 +24,7 @@ class Element(Visibility): - component: Optional[JsComponent] = None + component: Optional[Component] = None libraries: List[Library] = [] extra_libraries: List[Library] = [] exposed_libraries: List[Library] = [] @@ -252,7 +252,7 @@ def tooltip(self, text: str) -> Self: def on(self, type: str, # pylint: disable=redefined-builtin handler: Optional[Callable[..., Any]] = None, - args: Optional[List[str]] = None, *, + args: Union[None, Sequence[str], Sequence[Optional[Sequence[str]]]] = None, *, throttle: float = 0.0, leading_events: bool = True, trailing_events: bool = True, @@ -270,7 +270,7 @@ def on(self, listener = EventListener( element_id=self.id, type=type, - args=[args] if args and isinstance(args[0], str) else args, + args=[args] if args and isinstance(args[0], str) else args, # type: ignore handler=handler, throttle=throttle, leading_events=leading_events, diff --git a/nicegui/event_listener.py b/nicegui/event_listener.py index 456391fd0..d14c30177 100644 --- a/nicegui/event_listener.py +++ b/nicegui/event_listener.py @@ -1,6 +1,6 @@ import uuid from dataclasses import dataclass, field -from typing import Any, Callable, Dict, List, Optional +from typing import Any, Callable, Dict, Optional, Sequence from fastapi import Request @@ -12,7 +12,7 @@ class EventListener: id: str = field(init=False) element_id: int type: str - args: List[Optional[List[str]]] + args: Sequence[Optional[Sequence[str]]] handler: Callable throttle: float leading_events: bool diff --git a/nicegui/page.py b/nicegui/page.py index 5d08fb7ba..d9be928f4 100644 --- a/nicegui/page.py +++ b/nicegui/page.py @@ -107,7 +107,7 @@ async def wait_for_result() -> None: if 'request' not in {p.name for p in parameters}: request = inspect.Parameter('request', inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=Request) parameters.insert(0, request) - decorated.__signature__ = inspect.Signature(parameters) + decorated.__signature__ = inspect.Signature(parameters) # type: ignore if 'include_in_schema' not in self.kwargs: self.kwargs['include_in_schema'] = globals.endpoint_documentation in {'page', 'all'}