From 6dff52fb591ddacb8d6a9132ba4ed91143824f20 Mon Sep 17 00:00:00 2001 From: Michael Harbarth <michael.harbarth@deutschebahn.com> Date: Wed, 9 Oct 2024 16:31:35 +0200 Subject: [PATCH] fix: support implementing additional functions in custom workitem classes --- polarion_rest_api_client/data_models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/polarion_rest_api_client/data_models.py b/polarion_rest_api_client/data_models.py index fdc8dd4..0fd9425 100644 --- a/polarion_rest_api_client/data_models.py +++ b/polarion_rest_api_client/data_models.py @@ -115,13 +115,13 @@ def __init__( def __getattribute__(self, item: str) -> t.Any: """Return all non WorkItem attributes from additional_properties.""" - if item.startswith("__") or item in dir(WorkItem): + if item.startswith("__") or item in dir(self.__class__): return super().__getattribute__(item) return self.additional_attributes.get(item) def __setattr__(self, key: str, value: t.Any): """Set all non WorkItem attributes in additional_properties.""" - if key in dir(WorkItem): + if key in dir(self.__class__): super().__setattr__(key, value) else: self.additional_attributes[key] = value @@ -140,7 +140,9 @@ def to_dict(self) -> dict[str, t.Any]: return { "id": self.id, "title": self.title, - "description": self.description.__dict__, + "description": ( + self.description.__dict__ if self.description else None + ), "type": self.type, "status": self.status, "additional_attributes": dict(