mirror of
https://github.com/tiqi-group/pydase.git
synced 2026-02-15 14:58:39 +01:00
suppresses KeyError when removing key from observable dict mapping
This error is thrown in some test cases when some object gets deleted but it's not within the dict mapping for some reason.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import weakref
|
import weakref
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
@@ -252,6 +253,7 @@ class _ObservableDict(ObservableObject, dict[str, Any]):
|
|||||||
self.__setitem__(key, self._initialise_new_objects(f'["{key}"]', value))
|
self.__setitem__(key, self._initialise_new_objects(f'["{key}"]', value))
|
||||||
|
|
||||||
def __del__(self) -> None:
|
def __del__(self) -> None:
|
||||||
|
with contextlib.suppress(KeyError):
|
||||||
self._dict_mapping.pop(id(self._original_dict))
|
self._dict_mapping.pop(id(self._original_dict))
|
||||||
|
|
||||||
def __setitem__(self, key: str, value: Any) -> None:
|
def __setitem__(self, key: str, value: Any) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user