mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-06 13:30:41 +02: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:
parent
24ecbd1eb9
commit
98e9791d09
@ -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,7 +253,8 @@ 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:
|
||||||
self._dict_mapping.pop(id(self._original_dict))
|
with contextlib.suppress(KeyError):
|
||||||
|
self._dict_mapping.pop(id(self._original_dict))
|
||||||
|
|
||||||
def __setitem__(self, key: str, value: Any) -> None:
|
def __setitem__(self, key: str, value: Any) -> None:
|
||||||
if not isinstance(key, str):
|
if not isinstance(key, str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user