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:
Mose Müller 2025-05-20 13:51:12 +02:00
parent 24ecbd1eb9
commit 98e9791d09

View File

@ -1,5 +1,6 @@
from __future__ import annotations
import contextlib
import logging
import weakref
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))
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:
if not isinstance(key, str):