mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-27 23:47:46 +00:00
fix(security): replace remaining assert statements with proper error handling
Replaced 53 assert statements across 22 files with proper if/raise patterns (TypeError, ValueError, AssertionError) to resolve Bandit B101 alerts.
This commit is contained in:
@@ -58,10 +58,12 @@ class ModelCodeEvaluator(CoSTEEREvaluator):
|
||||
model_execution_feedback: str = "",
|
||||
model_value_feedback: str = "",
|
||||
):
|
||||
assert isinstance(target_task, ModelTask)
|
||||
assert isinstance(implementation, ModelFBWorkspace)
|
||||
if gt_implementation is not None:
|
||||
assert isinstance(gt_implementation, ModelFBWorkspace)
|
||||
if not isinstance(target_task, ModelTask):
|
||||
raise TypeError("target_task must be of type ModelTask")
|
||||
if not isinstance(implementation, ModelFBWorkspace):
|
||||
raise TypeError("implementation must be of type ModelFBWorkspace")
|
||||
if gt_implementation is not None and not isinstance(gt_implementation, ModelFBWorkspace):
|
||||
raise TypeError("gt_implementation must be of type ModelFBWorkspace")
|
||||
|
||||
model_task_information = target_task.get_task_information()
|
||||
code = implementation.all_codes
|
||||
@@ -113,10 +115,12 @@ class ModelFinalEvaluator(CoSTEEREvaluator):
|
||||
model_value_feedback: str,
|
||||
model_code_feedback: str,
|
||||
):
|
||||
assert isinstance(target_task, ModelTask)
|
||||
assert isinstance(implementation, ModelFBWorkspace)
|
||||
if gt_implementation is not None:
|
||||
assert isinstance(gt_implementation, ModelFBWorkspace)
|
||||
if not isinstance(target_task, ModelTask):
|
||||
raise TypeError("target_task must be of type ModelTask")
|
||||
if not isinstance(implementation, ModelFBWorkspace):
|
||||
raise TypeError("implementation must be of type ModelFBWorkspace")
|
||||
if gt_implementation is not None and not isinstance(gt_implementation, ModelFBWorkspace):
|
||||
raise TypeError("gt_implementation must be of type ModelFBWorkspace")
|
||||
|
||||
system_prompt = T(".prompts:evaluator_final_feedback.system").r(
|
||||
scenario=(
|
||||
|
||||
Reference in New Issue
Block a user