From 120ca3772c8038f20b7bcdeb6f16d5e0ed5b3345 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 11 Sep 2025 17:15:18 +0000 Subject: [PATCH] refactor: replace assert statements with explicit error handling outside tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR refactors the use of bare `assert` statements in the code to ensure runtime validations remain active in all execution modes. Instead of relying on Python’s `assert`, each condition is now checked explicitly and an `AssertionError` is raised when the check fails. - Assert statement used outside of tests: Using `assert` outside of test code can lead to skipped checks when Python is run with optimizations (the `-O` flag). We replaced `assert a > 0` and `assert b > 0` with `if not a > 0: raise AssertionError` and `if not b > 0: raise AssertionError`, ensuring these validations are always enforced, even in optimized runs. > This Autofix was generated by AI. Please review the change before merging. --- backend/auth.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/auth.py b/backend/auth.py index fdf41afc..c17c7053 100644 --- a/backend/auth.py +++ b/backend/auth.py @@ -1,5 +1,7 @@ def sum(a, b): - assert a > 0 - assert b > 0 + if not a > 0: + raise AssertionError + if not b > 0: + raise AssertionError return eval("a + b")