Skip to content

Commit 52a8af1

Browse files
evnchnclaude
andcommitted
Fix mypy and pylint errors in js_action integration
- Add type: ignore for update_wrapper on _JsActionDescriptor - Add type: ignore for JsAction callbacks passed to on() in fab/dropdown - Replace ValueElement import with hasattr check to break cyclic import (nicegui.element -> nicegui.js_action -> nicegui.elements.mixins.value_element) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dfd39cd commit 52a8af1

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

nicegui/elements/button_dropdown.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def on_click(self, callback: Handler[ClickEventArguments]) -> Self:
5757
*Added in version 2.22.0*
5858
"""
5959
if has_js_action(callback):
60-
self.on('click', callback, [])
60+
self.on('click', callback, []) # type: ignore[arg-type]
6161
else:
6262
self.on('click', lambda _: handle_event(callback, ClickEventArguments(sender=self, client=self.client)), [])
6363
return self

nicegui/elements/fab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(self,
8686
def on_click(self, callback: Handler[ClickEventArguments]) -> Self:
8787
"""Add a callback to be invoked when the action element is clicked."""
8888
if has_js_action(callback):
89-
self.on('click', callback, [])
89+
self.on('click', callback, []) # type: ignore[arg-type]
9090
else:
9191
self.on('click', lambda _: handle_event(callback, ClickEventArguments(sender=self, client=self.client)), [])
9292
return self

nicegui/js_action.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ def _call_without_loopback(self) -> Any:
3939
4040
Used when the action was already applied on the client via JavaScript.
4141
"""
42-
from .elements.mixins.value_element import ValueElement # pylint: disable=import-outside-toplevel
4342
element = self._element
44-
if isinstance(element, ValueElement):
43+
if hasattr(element, '_send_update_on_value_change'):
4544
prev = element._send_update_on_value_change # pylint: disable=protected-access
4645
element._send_update_on_value_change = False # pylint: disable=protected-access
4746
try:
@@ -59,7 +58,7 @@ def __init__(self, method: Callable, js_handler_factory: Callable[[Any], str]) -
5958
raise TypeError(f'@js_action does not support async methods (got {method!r})')
6059
self._method = method
6160
self._js_handler_factory = js_handler_factory
62-
functools.update_wrapper(self, method)
61+
functools.update_wrapper(self, method) # type: ignore[arg-type]
6362

6463
def __get__(self, obj: Any, objtype: type | None = None) -> Any:
6564
if obj is None:

0 commit comments

Comments
 (0)