From 686d755ba7a4abfe322dae7d8371d20679a8c575 Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Thu, 5 Dec 2024 13:17:36 -0500 Subject: [PATCH] Replace asserts with boolean logic chaining --- librarian_background/rolling_deletion.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/librarian_background/rolling_deletion.py b/librarian_background/rolling_deletion.py index 3983171..a364af8 100644 --- a/librarian_background/rolling_deletion.py +++ b/librarian_background/rolling_deletion.py @@ -107,11 +107,11 @@ def core(self, session: Session): return False # Check that we got what we wanted. - try: - assert instance.created_time.replace(tzinfo=timezone.utc) < age_cutoff - assert instance.store_id == store.id - assert instance.available - except AssertionError: + valid_time = instance.created_time.replace(tzinfo=timezone.utc) < age_cutoff + valid_store = instance.store_id == store.id + all_ok = valid_time and valid_store and instance.available + + if not all_ok: logger.error( "Instance {} does not meet the criteria, skipping", instance.id )