Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Replaced assert Statements with Error Handling for Length Mismatch" #577

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/attributecode/attrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,19 @@ 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):
error_message = (
f"Mismatch in lengths: lic_key has {len(lic_key)} elements "
f"but lic_name has {len(lic_name)} elements. Ensure the data is consistent."
)
raise ValueError(error_message)

if len(lic_key) != len(lic_score):
error_message = (
f"Mismatch in lengths: lic_key has {len(lic_key)} elements "
f"but lic_score has {len(lic_score)} elements. Ensure the data is consistent."
)
raise ValueError(error_message)

lic_key_expression = about.license_key_expression.value
if lic_key_expression:
Expand Down
Loading