From 97d484917d09867e16fc17cc4cc3cca490ed4f73 Mon Sep 17 00:00:00 2001 From: Dhruv276R Date: Tue, 14 Jan 2025 11:36:17 +0530 Subject: [PATCH 1/2] Rewritten assert statements for more explicit checks --- src/attributecode/attrib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/attributecode/attrib.py b/src/attributecode/attrib.py index b22c6d93..b0062d96 100644 --- a/src/attributecode/attrib.py +++ b/src/attributecode/attrib.py @@ -193,8 +193,12 @@ def generate_sctk_input(abouts, min_license_score, license_dict): for key in lic_key: lic_name.append(license_dict[key][0]) lic_score = about.license_score.value - assert len(lic_key) == len(lic_name) - assert len(lic_key) == len(lic_score) + if len(lic_key) != len(lic_name): + raise ValueError("Mismatch in length: 'lic_key' and 'lic_name' must have the same number of elements") + + if len(lic_key) != len(lic_score): + raise ValueError("Mismatch in length: 'lic_key' and 'lic_score' must have the same number of elements") + lic_key_expression = about.license_key_expression.value if lic_key_expression: From c89af652da7d926538778932d5fa1ad2cd33e791 Mon Sep 17 00:00:00 2001 From: Dhruv276R <82694402+Dhruv276R@users.noreply.github.com> Date: Sat, 18 Jan 2025 12:04:01 +0530 Subject: [PATCH 2/2] Did the requested changes for attrib.py --- src/attributecode/attrib.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/attributecode/attrib.py b/src/attributecode/attrib.py index b0062d96..ec4ba716 100644 --- a/src/attributecode/attrib.py +++ b/src/attributecode/attrib.py @@ -194,10 +194,17 @@ def generate_sctk_input(abouts, min_license_score, license_dict): lic_name.append(license_dict[key][0]) lic_score = about.license_score.value if len(lic_key) != len(lic_name): - raise ValueError("Mismatch in length: 'lic_key' and 'lic_name' must have the same number of elements") + raise ValueError( + f"Mismatch in length: 'lic_key' and 'lic_name' must have the same number of elements. " + f"Got lic_key={lic_key} with length {len(lic_key)}, and lic_name={lic_name} with length {len(lic_name)}" + ) if len(lic_key) != len(lic_score): - raise ValueError("Mismatch in length: 'lic_key' and 'lic_score' must have the same number of elements") + raise ValueError( + f"Mismatch in length: 'lic_key' and 'lic_score' must have the same number of elements. " + f"Got lic_key={lic_key} with length {len(lic_key)}, and lic_score={lic_score} with length {len(lic_score)}" + ) + lic_key_expression = about.license_key_expression.value