fixes detection of property dependencies for classes inheriting from other observables

Inheriting from a class that itself has defined properties, you cannot get those properties by calling
vars(type(obj)). Instead, you have to go through all the classes' members and check if they are properties.
You can either do this using dir(type(obj)) and get the members using getattr or just use inspect.getmembers.
This commit is contained in:
Mose Müller 2024-04-08 09:24:52 +02:00
parent 73b2355d35
commit 5b762db535

View File

@ -49,7 +49,7 @@ class PropertyObserver(Observer):
def _process_observable_properties( def _process_observable_properties(
self, obj: Observable, deps: dict[str, Any], prefix: str self, obj: Observable, deps: dict[str, Any], prefix: str
) -> None: ) -> None:
for k, value in vars(type(obj)).items(): for k, value in inspect.getmembers(type(obj)):
prefix = ( prefix = (
f"{prefix}." if prefix != "" and not prefix.endswith(".") else prefix f"{prefix}." if prefix != "" and not prefix.endswith(".") else prefix
) )