From aa6c5152311070fa9407e42f95f681d660546570 Mon Sep 17 00:00:00 2001
From: Leander Karp <karp@cl.uni-heidelberg.de>
Date: Wed, 7 Aug 2024 16:19:16 +0200
Subject: [PATCH] Fix type annotation of UUID

According to mypy the previous annotation violated the LSP.
Therefore, we use the types of the supertype method and check for
correct types in the method.
---
 portal/model/Uuid.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/portal/model/Uuid.py b/portal/model/Uuid.py
index 5eb2a46..452b477 100644
--- a/portal/model/Uuid.py
+++ b/portal/model/Uuid.py
@@ -26,12 +26,12 @@ class Uuid(types.TypeDecorator):
     def load_dialect_impl(self, dialect: Dialect) -> types.TypeEngine[Any]:
         return types.String(UUID_LENGTH)
 
-    def process_bind_param(self, value: str | UUID, dialect: Dialect) -> Optional[str]:
+    def process_bind_param(self, value: Any | None, dialect: Dialect) -> Optional[str]:
         if isinstance(value, str):
             # Manually create UUID from string, to raise an error if the string is malformed
             UUID(value)
 
-        return str(value) if value else None
+        return str(value) if isinstance(value, UUID) else None
 
     def process_result_value(
         self, value: Optional[str], dialect: Dialect
-- 
GitLab