diff --git a/unstructured/staging/label_studio.py b/unstructured/staging/label_studio.py index bdb3989e03..c99e579650 100644 --- a/unstructured/staging/label_studio.py +++ b/unstructured/staging/label_studio.py @@ -1,4 +1,3 @@ -from copy import deepcopy from dataclasses import dataclass from typing import Any, Dict, List, Optional, Union @@ -84,16 +83,13 @@ class LabelStudioAnnotation: was_canceled: bool = False # Indicates whether or not the annotation was canceled def to_dict(self): - annotation_dict = deepcopy(self.__dict__) + annotation_dict = dict(self.__dict__) annotation_dict["result"] = [r.to_dict() for r in annotation_dict["result"]] if "reviews" in annotation_dict and annotation_dict["reviews"] is not None: annotation_dict["reviews"] = [r.to_dict() for r in annotation_dict["reviews"]] # NOTE(robinson) - Removes keys for any fields that defaulted to None - _annotation_dict = deepcopy(annotation_dict) - for key, value in annotation_dict.items(): - if value is None: - _annotation_dict.pop(key) + _annotation_dict = {k: v for k, v in annotation_dict.items() if v is not None} return _annotation_dict