Skip to content

Commit

Permalink
Ruff: Add and fix RUF005 (#10714)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik authored Aug 13, 2024
1 parent 6091ba4 commit 23553d0
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dojo/api_v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def get_indent(self, accepted_media_type, renderer_context):


class DojoSpectacularAPIView(SpectacularAPIView):
renderer_classes = [DojoOpenApiJsonRenderer] + SpectacularAPIView.renderer_classes
renderer_classes = [DojoOpenApiJsonRenderer, *SpectacularAPIView.renderer_classes]


class DojoModelViewSet(
Expand Down
2 changes: 1 addition & 1 deletion dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _get_statistics_for_queryset(qs, annotation_factory):
# add annotation for each status field
values = values.annotate(**annotation_factory())
# make sure sev and total are included
stat_fields = ["sev", "total"] + STATS_FIELDS
stat_fields = ["sev", "total", *STATS_FIELDS]
# go for it
values = values.values(*stat_fields)

Expand Down
2 changes: 1 addition & 1 deletion dojo/request_cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def cache_calculate_key(*args, **kwargs):
:rtype: basestring
"""
# combine args with kwargs, separated by the cache_args_kwargs_marker
key = args + (cache_args_kwargs_marker,) + tuple(sorted(kwargs.items()))
key = (*args, cache_args_kwargs_marker, *tuple(sorted(kwargs.items())))
# return as a string
return str(key)

Expand Down
2 changes: 1 addition & 1 deletion dojo/settings/.settings.dist.py.sha256sum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
08983f823deebc1e086953c39abaa8ebeafb4dd4b470248af75ce7bd98aeebb6
7a605674ff68576fef116e62103d11d55f25fb8dc15c87b93e850dde56604639
10 changes: 6 additions & 4 deletions dojo/settings/settings.dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,10 +1159,12 @@ def saml2_attrib_map_format(dict):
# django metrics for monitoring
if env("DD_DJANGO_METRICS_ENABLED"):
DJANGO_METRICS_ENABLED = env("DD_DJANGO_METRICS_ENABLED")
INSTALLED_APPS = INSTALLED_APPS + ("django_prometheus",)
MIDDLEWARE = ["django_prometheus.middleware.PrometheusBeforeMiddleware"] + \
MIDDLEWARE + \
["django_prometheus.middleware.PrometheusAfterMiddleware"]
INSTALLED_APPS = (*INSTALLED_APPS, "django_prometheus")
MIDDLEWARE = [
"django_prometheus.middleware.PrometheusBeforeMiddleware",
*MIDDLEWARE,
"django_prometheus.middleware.PrometheusAfterMiddleware",
]
database_engine = DATABASES.get("default").get("ENGINE")
DATABASES["default"]["ENGINE"] = database_engine.replace("django.", "django_prometheus.", 1)
# CELERY_RESULT_BACKEND.replace('django.core','django_prometheus.', 1)
Expand Down
18 changes: 9 additions & 9 deletions dojo/user/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ def get_configuration_permissions_fields():
permission_fields = [
Permission_Helper(name="cred user", app="dojo", view=True, add=True, change=True, delete=True),
Permission_Helper(name="development environment", app="dojo", add=True, change=True, delete=True),
Permission_Helper(name="finding template", app="dojo", view=True, add=True, change=True, delete=True)] + \
github_permissions + \
google_sheet_permissions + [
Permission_Helper(name="group", app="auth", view=True, add=True)] + \
jira_permissions + [
Permission_Helper(name="finding template", app="dojo", view=True, add=True, change=True, delete=True),
*github_permissions,
*google_sheet_permissions,
Permission_Helper(name="group", app="auth", view=True, add=True),
*jira_permissions,
Permission_Helper(name="language type", app="dojo", view=True, add=True, change=True, delete=True),
Permission_Helper(name="bannerconf", app="dojo", change=True),
Permission_Helper(name="announcement", app="dojo", change=True),
Permission_Helper(name="note type", app="dojo", view=True, add=True, change=True, delete=True),
Permission_Helper(name="product type", app="dojo", add=True)] + \
questionnaire_permissions + [
Permission_Helper(name="regulation", app="dojo", add=True, change=True, delete=True)] + \
rules_permissions + [
Permission_Helper(name="product type", app="dojo", add=True),
*questionnaire_permissions,
Permission_Helper(name="regulation", app="dojo", add=True, change=True, delete=True),
*rules_permissions,
Permission_Helper(name="sla configuration", app="dojo", view=True, add=True, change=True, delete=True),
Permission_Helper(name="test type", app="dojo", add=True, change=True),
Permission_Helper(name="tool configuration", app="dojo", view=True, add=True, change=True, delete=True),
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ select = [
"AIR",
"FURB",
"RUF1","RUF2",
"RUF001","RUF002", "RUF003",
"RUF001","RUF002", "RUF003", "RUF005",
"RUF013",
"RUF019",
"RUF025",
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_jira_import_and_pushing_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def test_import_with_push_to_jira_update_tags(self):
# Assert that the tags match
self.assertEqual(issue.fields.labels, tags)

tags_new = tags + ["tag3", "tag4"]
tags_new = [*tags, "tag3", "tag4"]
self.post_finding_tags_api(finding.id, tags_new)
self.patch_finding_api(finding.id, {"push_to_jira": True})

Expand Down
4 changes: 2 additions & 2 deletions unittests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def test_import_with_tags_then_reimport_with_different_tag(self):
product_tags = self._convert_instance_tags_to_list(self.product)
self.assertEqual(product_tags, self._convert_instance_tags_to_list(objects.get("engagement")))
self.assertEqual(product_tags, self._convert_instance_tags_to_list(objects.get("endpoint")))
self.assertEqual(["import_tag"] + product_tags, self._convert_instance_tags_to_list(objects.get("test")))
self.assertEqual(["import_tag", *product_tags], self._convert_instance_tags_to_list(objects.get("test")))
self.assertEqual(product_tags, self._convert_instance_tags_to_list(objects.get("finding")))
# Reimport now
objects = self._import_and_return_objects(test_id=objects.get("test").id, reimport=True, tags=["reimport_tag"])
Expand All @@ -318,7 +318,7 @@ def test_new_engagement_then_add_tag_to_engagement_then_remove_tag_to_engagement
engagement_tags_before_addition = self._convert_instance_tags_to_list(engagement)
engagement.tags.add("engagement_only_tag")
# Check to see that the update was successful
self.assertEqual(["engagement_only_tag"] + engagement_tags_before_addition, self._convert_instance_tags_to_list(engagement))
self.assertEqual(["engagement_only_tag", *engagement_tags_before_addition], self._convert_instance_tags_to_list(engagement))
# Check to see that tests were not impacted
self.assertEqual(product_tags, self._convert_instance_tags_to_list(test))
# remove a tag on the engagement
Expand Down

0 comments on commit 23553d0

Please sign in to comment.