Skip to content

Commit

Permalink
fix: support implementing additional functions in custom workitem cla…
Browse files Browse the repository at this point in the history
…sses
  • Loading branch information
micha91 committed Oct 9, 2024
1 parent e6f35aa commit 6dff52f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions polarion_rest_api_client/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 6dff52f

Please sign in to comment.