Jelajahi Sumber

fix type annotation to allow a subset of arguments

Falko Schindler 1 tahun lalu
induk
melakukan
0c7547b657
2 mengubah file dengan 7 tambahan dan 3 penghapusan
  1. 1 1
      examples/chat_app/main.py
  2. 6 2
      nicegui/functions/refreshable.py

+ 1 - 1
examples/chat_app/main.py

@@ -21,7 +21,7 @@ async def main(client: Client):
         stamp = datetime.utcnow().strftime('%X')
         messages.append((user_id, avatar, text.value, stamp))
         text.value = ''
-        chat_messages.refresh(user_id)
+        chat_messages.refresh()
 
     user_id = str(uuid4())
     avatar = f'https://robohash.org/{user_id}?bgset=bg2'

+ 6 - 2
nicegui/functions/refreshable.py

@@ -86,8 +86,12 @@ class refreshable(Generic[_P, _T]):
         self.targets.append(target)
         return target.run(self.func)
 
-    def refresh(self, *args: _P.args, **kwargs: _P.kwargs) -> None:
-        """Refresh the UI elements created by this function."""
+    def refresh(self, *args: Any, **kwargs: Any) -> None:
+        """Refresh the UI elements created by this function.
+
+        This method accepts the same arguments as the function itself or a subset of them.
+        It will combine the arguments passed to the function with the arguments passed to this method.
+        """
         self.prune()
         for target in self.targets:
             if target.instance != self.instance: