diff --git a/src/caosdb/apiutils.py b/src/caosdb/apiutils.py
index fcc200b799f6b6a662df2bb59d6385c772dae50f..5558f649f5ff06401273ce5059b9114e421df930 100644
--- a/src/caosdb/apiutils.py
+++ b/src/caosdb/apiutils.py
@@ -33,6 +33,8 @@ import warnings
 from collections.abc import Iterable
 from subprocess import call
 
+from typing import Optional, Any
+
 from caosdb.common.datatype import (BOOLEAN, DATETIME, DOUBLE, FILE, INTEGER,
                                     REFERENCE, TEXT, is_reference)
 from caosdb.common.models import (Container, Entity, File, Property, Query,
@@ -205,8 +207,8 @@ def compare_entities(old_entity: Entity, new_entity: Entity):
         In case of changed information the value listed under the respective key shows the
         value that is stored in the respective entity.
     """
-    olddiff = {"properties": {}, "parents": []}
-    newdiff = {"properties": {}, "parents": []}
+    olddiff: dict[str, Any] = {"properties": {}, "parents": []}
+    newdiff: dict[str, Any] = {"properties": {}, "parents": []}
 
     if old_entity is new_entity:
         return (olddiff, newdiff)
@@ -307,6 +309,7 @@ def copy_entity(entity: Entity):
     If deep == True return a deep copy, recursively copying all sub entities.
     """
     print(entity)
+    new: Optional[Entity] = None
     if entity.role == "File":
         new = File()
     elif entity.role == "Property":