From 1d831f39275d1615a51280958c0520aff1c627ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maurice=20Hern=C3=A9?= <maurice.herne@rwth-aachen.de>
Date: Thu, 7 Nov 2024 00:34:54 +0100
Subject: [PATCH] Replaces type assertion in configuration_model.py assert will
 be removed when compiling to optimized bytecode. This can lead to UB. Instead
 we are now using if not isinstance(): raise TypeError().

---
 .../configuration/models/configuration_model.py               | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/Notebook_Processor/configuration/models/configuration_model.py b/src/Notebook_Processor/configuration/models/configuration_model.py
index de35bd7..7f24827 100644
--- a/src/Notebook_Processor/configuration/models/configuration_model.py
+++ b/src/Notebook_Processor/configuration/models/configuration_model.py
@@ -29,7 +29,9 @@ class ConfigurationModel(ConfiguredBaseModel):
         Causes defaults to get validated as a side effect.
         Since this only happens during the startup of the application, I consider this to be a positive side effect that protects against errors.
         """
-        assert isinstance(data, dict)
+        if not isinstance(data, dict):
+            raise TypeError(f"data must be a dict, not {type(data)}")
+
         for field, info in cls.model_fields.items():
             data.setdefault(field, environ.get(field, info.default))
         return data
-- 
GitLab