From 36e30970c5c4a0477a7afcf1dc38e0f6f7fe4dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Tue, 30 Apr 2024 13:39:38 +0200 Subject: [PATCH] adds dict.pop to pydase.Client The pop method removes the element in the dictionary on the server, but it will not return anything. This is because pop will delete the element on the server, and returned proxy classes will not be meaningful. --- src/pydase/client/proxy_loader.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pydase/client/proxy_loader.py b/src/pydase/client/proxy_loader.py index 46914fd..08137cd 100644 --- a/src/pydase/client/proxy_loader.py +++ b/src/pydase/client/proxy_loader.py @@ -97,6 +97,14 @@ class ProxyDict(dict[str | float, Any]): update_value(self._sio, self._loop, full_access_path, value) + def pop(self, key: str) -> Any: + """Removes the element from the dictionary on the server. It does not return + any proxy as the corresponding object on the server does not live anymore.""" + + full_access_path = f"{self._parent_path}.pop" + + trigger_method(self._sio, self._loop, full_access_path, [key], {}) + class ProxyList(list[Any]): def __init__(