Skip to content

Commit

Permalink
Ruff: Add and fix PLW0108
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Jan 30, 2025
1 parent 420bf66 commit d5f4829
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dojo/finding/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def reset_duplicate_before_delete(dupe):


def reset_duplicates_before_delete(qs):
mass_model_updater(Finding, qs, lambda f: reset_duplicate_before_delete(f), fields=["duplicate", "duplicate_finding"])
mass_model_updater(Finding, qs, reset_duplicate_before_delete, fields=["duplicate", "duplicate_finding"])


def set_new_original(finding, new_original):
Expand Down
4 changes: 2 additions & 2 deletions dojo/management/commands/dedupe.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def handle(self, *args, **options):

# only prefetch here for hash_code calculation
finds = findings.prefetch_related("endpoints", "test__test_type")
mass_model_updater(Finding, finds, lambda f: generate_hash_code(f), fields=["hash_code"], order="asc", log_prefix="hash_code computation ")
mass_model_updater(Finding, finds, generate_hash_code, fields=["hash_code"], order="asc", log_prefix="hash_code computation ")

logger.info("######## Done Updating Hashcodes########")

Expand All @@ -76,7 +76,7 @@ def handle(self, *args, **options):
if get_system_setting("enable_deduplication"):
logger.info("######## Start deduplicating (%s) ########", ("foreground" if dedupe_sync else "background"))
if dedupe_sync:
mass_model_updater(Finding, findings, lambda f: do_dedupe_finding(f), fields=None, order="desc", page_size=100, log_prefix="deduplicating ")
mass_model_updater(Finding, findings, do_dedupe_finding, fields=None, order="desc", page_size=100, log_prefix="deduplicating ")
else:
# async tasks only need the id
mass_model_updater(Finding, findings.only("id"), lambda f: do_dedupe_finding_task(f.id), fields=None, order="desc", log_prefix="deduplicating ")
Expand Down
4 changes: 2 additions & 2 deletions dojo/management/commands/migrate_cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def handle(self, *args, **options):
mass_model_updater(
Finding,
findings,
lambda f: create_vulnerability_id(f),
create_vulnerability_id,
fields=None,
page_size=100,
log_prefix="creating vulnerability ids: ",
Expand All @@ -49,7 +49,7 @@ def handle(self, *args, **options):
mass_model_updater(
Finding_Template,
finding_templates,
lambda f: create_vulnerability_id_template(f),
create_vulnerability_id_template,
fields=None,
page_size=100,
log_prefix="creating vulnerability ids: ",
Expand Down
2 changes: 1 addition & 1 deletion dojo/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def update_product_access(backend, uid, user=None, social=None, *args, **kwargs)

def sanitize_username(username):
allowed_chars_regex = re.compile(r"[\w@.+_-]")
allowed_chars = filter(lambda char: allowed_chars_regex.match(char), list(username))
allowed_chars = filter(allowed_chars_regex.match, list(username))
return "".join(allowed_chars)


Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ select = [
"PLC01", "PLC0205", "PLC0208", "PLC0414", "PLC24", "PLC3",
"PLE",
"PLR01", "PLR0203", "PLR0206", "PLR0915", "PLR1716", "PLR172", "PLR1733", "PLR1736",
"PLW0120", "PLW0129", "PLW013", "PLW017", "PLW02", "PLW04", "PLW07", "PLW1", "PLW2", "PLW3",
"PLW0108", "PLW0120", "PLW0129", "PLW013", "PLW017", "PLW02", "PLW04", "PLW07", "PLW1", "PLW2", "PLW3",
"TRY003", "TRY004", "TRY2",
"FLY",
"NPY",
Expand Down

0 comments on commit d5f4829

Please sign in to comment.