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

Rewritten assert statements for more explicit checks #574

Open
wants to merge 2 commits 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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be you can extract a variable?

Suggested change
if len(lic_key) != len(lic_name):
len_lics = len(lic_key)
if len_lics != len(lic_name):

and then use it in the messages and other tests below?

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(
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)}"
)


Dhruv276R marked this conversation as resolved.
Show resolved Hide resolved

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