Skip to content

Commit

Permalink
fixed ruff linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
karacolada committed Apr 10, 2024
1 parent e90842c commit 81ccd4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
26 changes: 13 additions & 13 deletions fuji_server/evaluators/fair_evaluator_license_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,28 @@ def setLicenseDataAndOutput(self):
if isinstance(specified_licenses, str): # licenses maybe string or list depending on metadata schemas
specified_licenses = [specified_licenses]
if specified_licenses is not None and specified_licenses != []:
for l in specified_licenses:
for license in specified_licenses:
isurl = False
licence_valid = False
license_output = LicenseOutputInner()
if isinstance(l, str):
isurl = idutils.is_url(l)
if isinstance(license, str):
isurl = idutils.is_url(license)
if isurl:
iscc, generic_cc = self.isCreativeCommonsLicense(l, self.metric_identifier)
iscc, generic_cc = self.isCreativeCommonsLicense(license, self.metric_identifier)
if iscc:
l = generic_cc
spdx_uri, spdx_osi, spdx_id = self.lookup_license_by_url(l, self.metric_identifier)
license = generic_cc
spdx_uri, spdx_osi, spdx_id = self.lookup_license_by_url(license, self.metric_identifier)
else: # maybe licence name
spdx_uri, spdx_osi, spdx_id = self.lookup_license_by_name(l, self.metric_identifier)
license_output.license = l
spdx_uri, spdx_osi, spdx_id = self.lookup_license_by_name(license, self.metric_identifier)
license_output.license = license
if spdx_uri:
licence_valid = True
license_output.details_url = spdx_uri
license_output.osi_approved = spdx_osi
self.output.append(license_output)
self.license_info.append(
{
"license": l,
"license": license,
"id": spdx_id,
"is_url": isurl,
"spdx_uri": spdx_uri,
Expand Down Expand Up @@ -223,14 +223,14 @@ def testLicenseIsValidAndSPDXRegistered(self):
)
)
if self.license_info: # license info is populated from recognised GitHub license
for l in self.license_info:
for license in self.license_info:
if test_required:
for rq_license_id in test_required:
if l.get("id"):
if fnmatch.fnmatch(l.get("id"), rq_license_id):
if license.get("id"):
if fnmatch.fnmatch(license.get("id"), rq_license_id):
test_status = True
else:
if l.get("valid"):
if license.get("valid"):
test_status = True
else:
self.logger.warning(
Expand Down
12 changes: 6 additions & 6 deletions fuji_server/evaluators/fair_evaluator_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ def nestedDataContainsKeyword(self, data, key):
bool: True if key found somewhere in nested structure.
"""
values = None
if type(data) == list:
if isinstance(data, list):
values = data
elif type(data) == dict:
elif isinstance(data, dict):
values = list(data.values())
else:
raise TypeError(
f"Can only recursively scan lists and dictionaries, but received data of type {type(data)}."
)
for d in values:
if type(d) == bytes:
if isinstance(d, bytes):
d = d.decode("utf-8")
if type(d) == str:
if isinstance(d, str):
if key in d.lower():
return True
else:
Expand Down Expand Up @@ -87,9 +87,9 @@ def scanForKeywords(self, keywords, locations):
for k in keys_to_check:
content = self.fuji.github_data.get(location)
if content is not None:
if type(content) == bytes:
if isinstance(content, bytes):
content = content.decode("utf-8")
if type(content) == str:
if isinstance(content, str):
if k in content.lower():
hit_dict[k] = True # found keyword in location
keys_to_check.remove(k) # stop looking, have found something for this key
Expand Down

0 comments on commit 81ccd4d

Please sign in to comment.