Skip to content

Commit b731d15

Browse files
fix: resolve ruff lint violations in helper and tests
1 parent 5d1f96b commit b731d15

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

dojo/finding/helper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ def reconfigure_duplicate_cluster(original, cluster_outside):
616616

617617

618618
def prepare_duplicates_for_delete(obj):
619-
"""Prepare duplicate clusters before deleting a Test, Engagement, Product, or Product_Type.
619+
"""
620+
Prepare duplicate clusters before deleting a Test, Engagement, Product, or Product_Type.
620621
621622
Resets inside-scope duplicate FKs and reconfigures outside-scope clusters
622623
so that cascade_delete won't hit FK violations on the self-referential
@@ -664,7 +665,7 @@ def prepare_duplicates_for_delete(obj):
664665
.iterator(chunk_size=500)
665666
)
666667

667-
for chunk_ids in batched(originals_ids, 500):
668+
for chunk_ids in batched(originals_ids, 500, strict=False):
668669
for original in Finding.objects.filter(id__in=chunk_ids).prefetch_related("original_finding"):
669670
# Inside-scope duplicates were already unlinked by the bulk UPDATE above,
670671
# so original_finding.all() now only contains outside-scope duplicates.

unittests/test_prepare_duplicates_for_delete.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ def test_mixed_inside_and_outside_duplicates(self):
225225

226226
@override_settings(DUPLICATE_CLUSTER_CASCADE_DELETE=True)
227227
def test_cascade_delete_skips_outside_reconfigure(self):
228-
"""When DUPLICATE_CLUSTER_CASCADE_DELETE=True, outside duplicates are left untouched.
228+
"""
229+
When DUPLICATE_CLUSTER_CASCADE_DELETE=True, outside duplicates are left untouched.
229230
230231
The caller (async_delete_crawl_task) handles deletion of outside-scope
231232
duplicates separately via bulk_delete_findings.
@@ -300,7 +301,8 @@ def test_found_by_copied_to_new_original(self):
300301
self.assertIn(test_type_2.id, found_by_ids)
301302

302303
def test_delete_finding_reconfigures_cross_engagement_duplicate(self):
303-
"""Deleting an original finding makes its cross-engagement duplicate standalone.
304+
"""
305+
Deleting an original finding makes its cross-engagement duplicate standalone.
304306
305307
Setup: product with eng A (finding A, original) and eng B (finding B, duplicate of A).
306308
Action: delete finding A.
@@ -331,13 +333,14 @@ def test_delete_finding_reconfigures_cross_engagement_duplicate(self):
331333
self.assertFalse(finding_b.is_mitigated)
332334

333335
def test_delete_product_with_cross_engagement_duplicates(self):
334-
"""Deleting a product with cross-engagement duplicates succeeds without FK violations.
336+
"""
337+
Deleting a product with cross-engagement duplicates succeeds without FK violations.
335338
336339
Setup: product with eng A (finding A, original) and eng B (finding B, duplicate of A).
337340
Action: delete the entire product via async_delete_crawl_task.
338341
Expected: product and all findings are deleted without errors.
339342
"""
340-
from dojo.utils import async_delete_crawl_task
343+
from dojo.utils import async_delete_crawl_task # noqa: PLC0415
341344

342345
finding_a = self._create_finding(self.test1, "Original A")
343346
finding_a.active = True

0 commit comments

Comments
 (0)