From 502bbdd7713574dd0410df14b2b72b4f6f242572 Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:48:18 +0100 Subject: [PATCH] Ruff: Fix DJ012 --- dojo/models.py | 54 +++++++++++++++++++++---------------------- requirements-lint.txt | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/dojo/models.py b/dojo/models.py index 99074a9cf3b..b718480bb47 100644 --- a/dojo/models.py +++ b/dojo/models.py @@ -1676,6 +1676,23 @@ class Meta: models.Index(fields=["product"]), ] + def __hash__(self): + return self.__str__().__hash__() + + def __eq__(self, other): + if isinstance(other, Endpoint): + # Check if the contents of the endpoint match + contents_match = str(self) == str(other) + # Determine if products should be used in the equation + if self.product is not None and other.product is not None: + # Check if the products are the same + products_match = (self.product) == other.product + # Check if the contents match + return products_match and contents_match + return contents_match + + return NotImplemented + def __str__(self): try: if self.host: @@ -1807,23 +1824,6 @@ def clean(self): if errors: raise ValidationError(errors) - def __hash__(self): - return self.__str__().__hash__() - - def __eq__(self, other): - if isinstance(other, Endpoint): - # Check if the contents of the endpoint match - contents_match = str(self) == str(other) - # Determine if products should be used in the equation - if self.product is not None and other.product is not None: - # Check if the products are the same - products_match = (self.product) == other.product - # Check if the contents match - return products_match and contents_match - return contents_match - - return NotImplemented - @property def is_broken(self): try: @@ -2622,6 +2622,16 @@ class Meta: models.Index(fields=["duplicate_finding", "id"]), ] + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.unsaved_endpoints = [] + self.unsaved_request = None + self.unsaved_response = None + self.unsaved_tags = None + self.unsaved_files = None + self.unsaved_vulnerability_ids = None + def __str__(self): return self.title @@ -2696,16 +2706,6 @@ def get_absolute_url(self): from django.urls import reverse return reverse("view_finding", args=[str(self.id)]) - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - self.unsaved_endpoints = [] - self.unsaved_request = None - self.unsaved_response = None - self.unsaved_tags = None - self.unsaved_files = None - self.unsaved_vulnerability_ids = None - def copy(self, test=None): copy = self # Save the necessary ManyToMany relationships diff --git a/requirements-lint.txt b/requirements-lint.txt index 8f161d317ec..d8e72aebe5c 100644 --- a/requirements-lint.txt +++ b/requirements-lint.txt @@ -1 +1 @@ -ruff==0.8.1 \ No newline at end of file +ruff==0.9.1 \ No newline at end of file