Skip to content

Commit 1b37284

Browse files
committed
Ruff: fix Q004
1 parent 8eaa550 commit 1b37284

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
lines changed

dojo/api_v2/permissions.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def has_permission(self, request, view):
437437
)
438438
elif engagement_id := converted_dict.get("engagement_id"):
439439
# engagement_id doesn't exist
440-
msg = f"Engagement \"{engagement_id}\" does not exist"
440+
msg = f'Engagement "{engagement_id}" does not exist'
441441
raise serializers.ValidationError(msg)
442442

443443
if not converted_dict.get("auto_create_context"):
@@ -492,7 +492,7 @@ def has_permission(self, request, view):
492492
)
493493
elif product_id := converted_dict.get("product_id"):
494494
# product_id doesn't exist
495-
msg = f"Product \"{product_id}\" does not exist"
495+
msg = f'Product "{product_id}" does not exist'
496496
raise serializers.ValidationError(msg)
497497
else:
498498
msg = "Need product_id or product_name to perform import"
@@ -633,7 +633,7 @@ def has_permission(self, request, view):
633633
)
634634
elif test_id := converted_dict.get("test_id"):
635635
# test_id doesn't exist
636-
msg = f"Test \"{test_id}\" does not exist"
636+
msg = f'Test "{test_id}" does not exist'
637637
raise serializers.ValidationError(msg)
638638

639639
if not converted_dict.get("auto_create_context"):
@@ -927,28 +927,28 @@ def raise_no_auto_create_import_validation_error(
927927
raise ValidationError(msg)
928928

929929
if product_type_name and not product_type:
930-
msg = f"Product Type \"{product_type_name}\" does not exist"
930+
msg = f'Product Type "{product_type_name}" does not exist'
931931
raise serializers.ValidationError(msg)
932932

933933
if product_name and not product:
934934
if product_type_name:
935-
msg = f"Product \"{product_name}\" does not exist in Product_Type \"{product_type_name}\""
935+
msg = f'Product "{product_name}" does not exist in Product_Type "{product_type_name}"'
936936
raise serializers.ValidationError(msg)
937937
else:
938-
msg = f"Product \"{product_name}\" does not exist"
938+
msg = f'Product "{product_name}" does not exist'
939939
raise serializers.ValidationError(msg)
940940

941941
if engagement_name and not engagement:
942-
msg = f"Engagement \"{engagement_name}\" does not exist in Product \"{product_name}\""
942+
msg = f'Engagement "{engagement_name}" does not exist in Product "{product_name}"'
943943
raise serializers.ValidationError(msg)
944944

945945
# these are only set for reimport
946946
if test_title:
947-
msg = f"Test \"{test_title}\" with scan_type \"{scan_type}\" does not exist in Engagement \"{engagement_name}\""
947+
msg = f'Test "{test_title}" with scan_type "{scan_type}" does not exist in Engagement "{engagement_name}"'
948948
raise serializers.ValidationError(msg)
949949

950950
if scan_type:
951-
msg = f"Test with scan_type \"{scan_type}\" does not exist in Engagement \"{engagement_name}\""
951+
msg = f'Test with scan_type "{scan_type}" does not exist in Engagement "{engagement_name}"'
952952
raise serializers.ValidationError(msg)
953953

954954
raise ValidationError(error_message)
@@ -995,28 +995,28 @@ def check_auto_create_permission(
995995

996996
if product and product_name and engagement_name:
997997
if not user_has_permission(user, product, Permissions.Engagement_Add):
998-
msg = f"No permission to create engagements in product \"{product_name}\""
998+
msg = f'No permission to create engagements in product "{product_name}"'
999999
raise PermissionDenied(msg)
10001000

10011001
if not user_has_permission(
10021002
user, product, Permissions.Import_Scan_Result
10031003
):
1004-
msg = f"No permission to import scans into product \"{product_name}\""
1004+
msg = f'No permission to import scans into product "{product_name}"'
10051005
raise PermissionDenied(msg)
10061006

10071007
# all good
10081008
return True
10091009

10101010
if not product and product_name:
10111011
if not product_type_name:
1012-
msg = f"Product \"{product_name}\" does not exist and no product_type_name provided to create the new product in"
1012+
msg = f'Product "{product_name}" does not exist and no product_type_name provided to create the new product in'
10131013
raise serializers.ValidationError(msg)
10141014

10151015
if not product_type:
10161016
if not user_has_global_permission(
10171017
user, Permissions.Product_Type_Add
10181018
):
1019-
msg = f"No permission to create product_type \"{product_type_name}\""
1019+
msg = f'No permission to create product_type "{product_type_name}"'
10201020
raise PermissionDenied(msg)
10211021
# new product type can be created with current user as owner, so
10221022
# all objects in it can be created as well
@@ -1025,7 +1025,7 @@ def check_auto_create_permission(
10251025
if not user_has_permission(
10261026
user, product_type, Permissions.Product_Type_Add_Product
10271027
):
1028-
msg = f"No permission to create products in product_type \"{product_type}\""
1028+
msg = f'No permission to create products in product_type "{product_type}"'
10291029
raise PermissionDenied(msg)
10301030

10311031
# product can be created, so objects in it can be created as well

dojo/importers/base_importer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ def sanitize_severity(
776776
# Ensure the final severity is one of the supported options
777777
if finding.severity not in SEVERITIES:
778778
msg = (
779-
f"Finding severity \"{finding.severity}\" is not supported. "
779+
f'Finding severity "{finding.severity}" is not supported. '
780780
f"Any of the following are supported: {SEVERITIES}."
781781
)
782782
raise ValidationError(msg)

dojo/importers/default_reimporter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def match_new_finding_to_existing_finding(
484484
severity=unsaved_finding.severity,
485485
numerical_severity=Finding.get_numerical_severity(unsaved_finding.severity)).order_by('id')
486486
else:
487-
logger.error(f"Internal error: unexpected deduplication_algorithm: \"{deduplication_algorithm}\"")
487+
logger.error(f'Internal error: unexpected deduplication_algorithm: "{deduplication_algorithm}"')
488488
return None
489489

490490
def process_matched_finding(

dojo/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ class System_Settings(models.Model):
553553
default=True,
554554
blank=False,
555555
verbose_name=_("Password must contain one special character"),
556-
help_text=_("Requires user passwords to contain at least one special character (()[]{}|\\`~!@#$%^&*_-+=;:\'\",<>./?)."))
556+
help_text=_("Requires user passwords to contain at least one special character (()[]{}|\\`~!@#$%^&*_-+=;:'\",<>./?)."))
557557
lowercase_character_required = models.BooleanField(
558558
default=True,
559559
blank=False,

dojo/utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2059,11 +2059,11 @@ def get_current_request():
20592059

20602060

20612061
def create_bleached_link(url, title):
2062-
link = '<a href=\"'
2062+
link = '<a href="'
20632063
link += url
2064-
link += '\" target=\"_blank\" title=\"'
2064+
link += '" target="_blank" title="'
20652065
link += title
2066-
link += '\">'
2066+
link += '">'
20672067
link += title
20682068
link += '</a>'
20692069
return bleach.clean(link, tags={'a'}, attributes={'a': ['href', 'target', 'title']})
@@ -2399,7 +2399,7 @@ def get_password_requirements_string():
23992399
if bool(get_system_setting('number_character_required')):
24002400
s += ', one number (0-9)'
24012401
if bool(get_system_setting('special_character_required')):
2402-
s += ', one special character (()[]{}|\\`~!@#$%^&*_-+=;:\'\",<>./?)'
2402+
s += ', one special character (()[]{}|\\`~!@#$%^&*_-+=;:\'",<>./?)'
24032403

24042404
if s.count(', ') == 1:
24052405
password_requirements_string = s.rsplit(', ', 1)[0] + ' and ' + s.rsplit(', ', 1)[1]

unittests/test_apiv2_endpoint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_endpoint_missing_host_product(self):
1919
"host": "FOO.BAR"
2020
}, format='json')
2121
self.assertEqual(r.status_code, 400, r.content[:1000])
22-
self.assertIn("Attribute \'product\' is required", r.content.decode("utf-8"))
22+
self.assertIn("Attribute 'product' is required", r.content.decode("utf-8"))
2323

2424
r = self.client.post(reverse('endpoint-list'), {
2525
"product": 1

0 commit comments

Comments
 (0)