From 07c10e03dee023929e60c7beebabcf1643fbf5b4 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Fri, 26 Jul 2024 10:27:25 +0200
Subject: [PATCH] fix: use if/raise instead of assert

---
 src/cal_tools/calcat_interface2.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/cal_tools/calcat_interface2.py b/src/cal_tools/calcat_interface2.py
index 406eedaf1..c35b36deb 100644
--- a/src/cal_tools/calcat_interface2.py
+++ b/src/cal_tools/calcat_interface2.py
@@ -500,8 +500,10 @@ class CalibrationData(Mapping):
         begin_at_strategy="closest",
     ):
         accepted_strategies = ["closest", "prior"]
-        strategy_error_msg = f"Invalid begin_at_strategy. Expected one of {accepted_strategies}"
-        assert begin_at_strategy in accepted_strategies, strategy_error_msg
+        if begin_at_strategy not in accepted_strategies:
+            raise ValueError(
+                "Invalid begin_at_strategy. "
+                f"Expected one of {accepted_strategies}")
 
         if calibrations is None:
             calibrations = set(condition.calibration_types)
-- 
GitLab