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

Dependencies upgrade #246

Merged
merged 10 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions component_catalog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def changeform_view(self, request, object_id=None, form_url="", extra_context=No
return super().changeform_view(request, object_id, form_url, extra_context)
except FormDataOutdated:
messages.error(
request, "Form data outdated or inconsistent. " "The form data has been refreshed."
request, "Form data outdated or inconsistent. The form data has been refreshed."
)
return redirect(request.path)

Expand Down Expand Up @@ -1019,7 +1019,7 @@ def collect_data_action(self, request, queryset):
if update_fields:
package.last_modified_by = request.user
package.save()
message = f'Data collected for: {", ".join(update_fields)}.'
message = f"Data collected for: {', '.join(update_fields)}."
History.log_change(request.user, package, message, serialized_data)
update_count += 1

Expand Down
5 changes: 2 additions & 3 deletions component_catalog/management/commands/setpurls.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def handle(self, *args, **options):
)
except Exception:
self.stderr.write(
f"Error encountered when processing Package:"
f" {str(package)} ({package.uuid})"
f"Error encountered when processing Package: {str(package)} ({package.uuid})"
)
self.stderr.write(traceback.format_exc())
error_count += 1
Expand All @@ -108,4 +107,4 @@ def handle(self, *args, **options):
self.stdout.write(self.style.SUCCESS(msg))
self.stdout.write("Pre-update: " + pre_update_summary)
self.stdout.write("Post-update: " + self.get_purl_summary(packages))
self.stdout.write(f"Number of errors encountered when updating Packages: " f"{error_count}")
self.stdout.write(f"Number of errors encountered when updating Packages: {error_count}")
2 changes: 1 addition & 1 deletion component_catalog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,7 @@ def collect_data(self, force_update=False, save=True):

if save:
self.save(update_fields=update_fields)
tasks_logger.info(f'Package field(s) updated: {", ".join(update_fields)}')
tasks_logger.info(f"Package field(s) updated: {', '.join(update_fields)}")

return update_fields

Expand Down
4 changes: 2 additions & 2 deletions component_catalog/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ def test_subcomponent_admin_license_expression_validation(self):
response = self.client.post(url, data)
expected = {
"license_expression": [
"Unknown license key(s): license2<br>" "Available licenses: license1"
"Unknown license key(s): license2<br>Available licenses: license1"
]
}
self.assertEqual(expected, response.context_data["adminform"].form.errors)
Expand Down Expand Up @@ -2485,7 +2485,7 @@ def test_package_changeform_save_and_collect_data_on_addition(self, mock_get):

response = self.client.post(add_url, data, follow=True)
expected = (
f'The SHA1, MD5, and Size fields collection from {data["download_url"]} is in progress.'
f"The SHA1, MD5, and Size fields collection from {data['download_url']} is in progress."
)
self.assertEqual(expected, list(response.context["messages"])[0].message)

Expand Down
2 changes: 1 addition & 1 deletion component_catalog/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def test_api_component_list_endpoint_uuid_filter(self):
expected = {
"uuid": [
ErrorDetail(
string="Select a valid choice. invalid is not one of " "the available choices.",
string="Select a valid choice. invalid is not one of the available choices.",
code="invalid_choice",
)
]
Expand Down
4 changes: 1 addition & 3 deletions component_catalog/tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ def test_collectcpes_management_command(self):
with self.assertRaises(CommandError) as error:
management.call_command("collectcpes", stdout=output)

expected = (
"Error: the following arguments are required: dataspace, " "cpe_dictionary_location"
)
expected = "Error: the following arguments are required: dataspace, cpe_dictionary_location"
self.assertEqual(expected, str(error.exception))

def test_componentfrompackage_management_command(self):
Expand Down
2 changes: 1 addition & 1 deletion component_catalog/tests/test_importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def test_component_import_clean_primary_language(self):
self.assertTrue(importer.formset.is_valid())
expected = {
"primary_language": [
'"What" is not in standard languages list.' "\nSuggestion(s): WebDNA, Whitespace."
'"What" is not in standard languages list.\nSuggestion(s): WebDNA, Whitespace.'
]
}
self.assertEqual(expected, importer.formset.forms[0].warnings)
Expand Down
2 changes: 1 addition & 1 deletion component_catalog/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ def test_package_model_set_package_url(self):
self.assertEqual("", package.subpath)
package.save()

package_url = f'pkg:maven/mysql/mysql-connector-java@%40MYSQL_CJ_.{"version"*100}'
package_url = f"pkg:maven/mysql/mysql-connector-java@%40MYSQL_CJ_.{'version' * 100}"
with self.assertRaises(ValidationError) as e:
package.set_package_url(package_url)
self.assertEqual('Value too long for field "version".', e.exception.message)
Expand Down
2 changes: 1 addition & 1 deletion component_catalog/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ def test_package_create_ajax_view(self):
response = self.client.get("/packages/")
messages = list(response.context["messages"])
msg = (
f'{collected_data["download_url"]} already exists in your Dataspace as '
f"{collected_data['download_url']} already exists in your Dataspace as "
f'<a href="{new_package.get_absolute_url()}">{new_package}</a>'
)
self.assertEqual(str(messages[0]), msg)
Expand Down
8 changes: 4 additions & 4 deletions component_catalog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def dispatch(self, request, *args, **kwargs):
if obj.dataspace != request.user.dataspace:
messages.error(
request,
("The dataspace of the selected objects did " "not match your dataspace."),
("The dataspace of the selected objects did not match your dataspace."),
)
return redirect(self.success_url)
return super().dispatch(request, *args, **kwargs)
Expand Down Expand Up @@ -1392,7 +1392,7 @@ def post_scan_to_package(self, form_class):
if form.is_valid():
if form.changed_data:
form.save()
msg = f'Values for {", ".join(form.changed_data)} assigned to the package.'
msg = f"Values for {', '.join(form.changed_data)} assigned to the package."
messages.success(request, msg)
else:
messages.warning(request, "No new values to assign.")
Expand Down Expand Up @@ -1711,7 +1711,7 @@ def send_scan_notification(request, key):
updated_fields = scancodeio.update_from_scan(package, user)
if updated_fields:
description = (
f'Automatically updated {", ".join(updated_fields)} from scan results\n'
f"Automatically updated {', '.join(updated_fields)} from scan results\n"
+ description
)

Expand Down Expand Up @@ -2286,7 +2286,7 @@ def scan_summary_fields(self, scan_summary):
(
f'<input type="{input_type}" name="{model_field_name}"'
f' value="{escape(entry.get("value"))}">'
f' {escape(entry.get("value"))}'
f" {escape(entry.get('value'))}"
f' <span class="badge text-bg-secondary rounded-pill">{entry.get("count")}'
f"</span>"
)
Expand Down
2 changes: 1 addition & 1 deletion dejacode_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, dataspace):
self.basic_auth_user = get_settings(f"{self.settings_prefix}_USER")
self.basic_auth_password = get_settings(f"{self.settings_prefix}_PASSWORD")

self.api_url = f'{self.service_url.rstrip("/")}/api/'
self.api_url = f"{self.service_url.rstrip('/')}/api/"

def get_session(self):
session = requests.Session()
Expand Down
2 changes: 1 addition & 1 deletion dejacode_toolkit/scancodeio.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def update_from_scan(self, package, user):
override_unknown=True,
)
if updated_fields:
msg = f'Automatically updated {", ".join(updated_fields)} from scan results'
msg = f"Automatically updated {', '.join(updated_fields)} from scan results"
logger.debug(f"{self.label}: {msg}")
History.log_change(user, package, message=msg)

Expand Down
4 changes: 1 addition & 3 deletions dje/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,9 +1426,7 @@ def get_form(self, request, obj=None, **kwargs):

permission_details_url = reverse("admin:auth_group_permission_details")
label_template = (
'{} <a href="{}" target="_blank" class="group-details-link">'
" (permission details)"
"</a>"
'{} <a href="{}" target="_blank" class="group-details-link"> (permission details)</a>'
)
groups_field.label = format_html(label_template, groups_field.label, permission_details_url)

Expand Down
2 changes: 1 addition & 1 deletion dje/importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def save_form(self, form):
)
if updated_fields:
self.results["modified"].append(instance)
msg = f'Updated {", ".join(updated_fields)} from import'
msg = f"Updated {', '.join(updated_fields)} from import"
History.log_change(self.user, instance, message=msg)
return

Expand Down
2 changes: 1 addition & 1 deletion dje/management/commands/checkdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def handle(self, *args, **options):
special_tags = ["reporting"], ["expression"]
if options["all_dataspaces"] and tags not in special_tags:
raise CommandError(
"--all-dataspaces only usable with `--tag reporting` or " "`--tag expression`"
"--all-dataspaces only usable with `--tag reporting` or `--tag expression`"
)

app_configs = {}
Expand Down
2 changes: 1 addition & 1 deletion dje/management/commands/checkmigrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def add_arguments(self, parser):
parser.add_argument(
"--database",
default=DEFAULT_DB_ALIAS,
help='Nominates a database to synchronize. Defaults to the "default" ' "database.",
help='Nominates a database to synchronize. Defaults to the "default" database.',
)

def handle(self, *args, **options):
Expand Down
2 changes: 1 addition & 1 deletion dje/management/commands/dumpdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def handle_field(self, obj, field):


class Command(BaseCommand):
help = "Output the contents of the all DejaCode data for the " "given Dataspace as a fixture."
help = "Output the contents of the all DejaCode data for the given Dataspace as a fixture."

def add_arguments(self, parser):
parser.add_argument("dataspace_name", help="Name of the Dataspace.")
Expand Down
2 changes: 1 addition & 1 deletion dje/mass_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def mass_update_action(modeladmin, request, queryset):
messages.info(request, _(f"Updated {updated} records"))

if errors:
messages.error(request, _(f'{len(errors)} error(s): {", ".join(errors)}'))
messages.error(request, _(f"{len(errors)} error(s): {', '.join(errors)}"))

action_end.send(
sender=modeladmin.model,
Expand Down
9 changes: 4 additions & 5 deletions dje/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ class ColoredIconMixin(models.Model):
blank=True,
max_length=7,
help_text=_(
"You can specify a valid HTML color code (e.g. #FFFFFF) to apply " "to your icon."
"You can specify a valid HTML color code (e.g. #FFFFFF) to apply to your icon."
),
)

Expand Down Expand Up @@ -1617,8 +1617,7 @@ class DejacodeUser(AbstractUser):
updates_email_notification = models.BooleanField(
default=False,
help_text=_(
"Check this to receive email notifications with updates on DejaCode "
"features and news."
"Check this to receive email notifications with updates on DejaCode features and news."
),
)

Expand Down Expand Up @@ -1932,13 +1931,13 @@ def log_deletion(cls, user, obj):
class ExternalSource(DataspacedModel):
label = models.CharField(
max_length=50,
help_text=_("A Label is a concise name of the external source as it " "is commonly known."),
help_text=_("A Label is a concise name of the external source as it is commonly known."),
)

notes = models.TextField(
blank=True,
help_text=_(
"Notes describe the purpose and special characteristics " "of the external source."
"Notes describe the purpose and special characteristics of the external source."
),
)

Expand Down
2 changes: 1 addition & 1 deletion dje/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def pull_project_data_from_scancodeio(scancodeproject_uuid):
scancode_project.append_to_log(msg)

for object_type, values in errors.items():
msg = f"- {len(values)} {object_type} error{pluralize(values)} " f"occurred during import."
msg = f"- {len(values)} {object_type} error{pluralize(values)} occurred during import."
scancode_project.append_to_log(msg)

scancode_project.save()
Expand Down
5 changes: 2 additions & 3 deletions dje/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ def __exit__(self, exc_type, exc_value, traceback):
self.test_case.assertLessEqual(
executed,
self.num,
"%d queries executed, %d max expected\nCaptured queries were:\n%s"
% (
"{} queries executed, {} max expected\nCaptured queries were:\n{}".format(
executed,
self.num,
"\n".join(
"%d. %s" % (i, query["sql"])
"{}. {}".format(i, query["sql"])
for i, query in enumerate(self.captured_queries, start=1)
),
),
Expand Down
13 changes: 5 additions & 8 deletions license_library/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class LicenseTag(DataspacedModel):
label = models.CharField(
max_length=50,
help_text=_(
"Organization-defined Label to identify a Tag that can be applied to a " "Tag Group."
"Organization-defined Label to identify a Tag that can be applied to a Tag Group."
),
)

Expand Down Expand Up @@ -311,13 +311,13 @@ class LicenseStatus(DataspacedModel):
code = models.CharField(
max_length=50,
help_text=_(
"Organization-defined Code to identify a Status that can be applied to a " "License."
"Organization-defined Code to identify a Status that can be applied to a License."
),
)

text = models.TextField(
help_text=_(
"Text to describe a Status that can be applied to a License by an " "Organization."
"Text to describe a Status that can be applied to a License by an Organization."
),
)

Expand Down Expand Up @@ -456,9 +456,7 @@ def render(self, template, as_link=False, show_policy=False, **kwargs):

if show_policy and self.usage_policy_id:
rendered = (
f'<span class="text-nowrap">'
f"{rendered}{self.get_usage_policy_icon_tooltip()}"
f"</span>"
f'<span class="text-nowrap">{rendered}{self.get_usage_policy_icon_tooltip()}</span>'
)

return rendered
Expand Down Expand Up @@ -572,8 +570,7 @@ class License(
_("Text URLs"),
blank=True,
help_text=_(
"URLs to the text of the license (plain text or HTML) on the main site of "
"this license."
"URLs to the text of the license (plain text or HTML) on the main site of this license."
),
)

Expand Down
8 changes: 4 additions & 4 deletions license_library/tests/test_search_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ def search_test_func(self):

# build a reasonably unique and valid function name
# based on the up to 50 chars from the query and a row number
test_func_name = "test_search_%04d_" % rownum + python_safe(
query[:50] + str(notes) if notes else ""
test_func_name = "test_search_{}_".format(
rownum + python_safe(query[:50] + str(notes) if notes else "")
)
# these are needed to ensure we can use the tests name for selection in discovery
search_test_func.__name__ = str(test_func_name)
Expand Down Expand Up @@ -225,7 +225,7 @@ def build_tsts_from_csv(csv_path, test_class):
- 7 and other columns: Expected results: Each column contains a license: use * if this
can be any license.
"""
with open(csv_path, "rU") as fin:
with open(csv_path) as fin:
import csv

reader = csv.reader(fin)
Expand All @@ -239,7 +239,7 @@ def build_tsts_from_csv(csv_path, test_class):
query = row[0]
if not query:
raise RuntimeError(
"Missing test query for row: %d of CSV file:%r" % (i + 1, csv_path)
"Missing test query for row: {} of CSV file:{}".format(i + 1, csv_path)
)
notes = row[1] if len(row) >= 2 else False
ordered = row[2] if len(row) >= 3 else False
Expand Down
2 changes: 1 addition & 1 deletion organization/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class OwnerFilterSet(DataspacedAPIFilterSet):
type = django_filters.ChoiceFilter(
choices=Owner.OWNER_TYPE_CHOICES,
help_text=f"Exact owner type. Supported values: "
f'{", ".join(type[0] for type in Owner.OWNER_TYPE_CHOICES)}',
f"{', '.join(type[0] for type in Owner.OWNER_TYPE_CHOICES)}",
)
last_modified_date = LastModifiedDateFilter()

Expand Down
2 changes: 1 addition & 1 deletion product_portfolio/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def render(self, name, value, attrs=None, renderer=None):
if value:
return (
f'<div class="object_display">'
f'<strong>{value.get_absolute_link(target="_blank")}</strong>'
f"<strong>{value.get_absolute_link(target='_blank')}</strong>"
f"</div>"
)

Expand Down
2 changes: 1 addition & 1 deletion product_portfolio/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def test_api_productcomponent_endpoint_create_license_expression_from_choice(sel
data["license_expression"] = self.license2.key
expected = {
"license_expression": [
"Unknown license key(s): license2<br>" "Available licenses: license1"
"Unknown license key(s): license2<br>Available licenses: license1"
]
}
response = self.client.post(self.productcomponent_list_url, data)
Expand Down
5 changes: 1 addition & 4 deletions product_portfolio/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,7 @@ def test_product_model_get_feature_values_and_get_feature_datalist(self):
self.assertEqual(expected, list(self.product1.get_feature_values(pc_queryset)))

expected = (
'<datalist id="feature_datalist">'
"<option>f1</option>"
"<option>f2</option>"
"</datalist>"
'<datalist id="feature_datalist"><option>f1</option><option>f2</option></datalist>'
)
self.assertEqual(expected, self.product1.get_feature_datalist())

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ max-complexity = 17
# Do not run bandit on test files.
"**/tests/*" = ["S"]
"dejacode_toolkit/csaf/*" = ["D", "UP", "E501", "F401"]
"dejacode_toolkit/spdx.py" = ["UP"]
Loading