Skip to content

Commit

Permalink
Ruff: Fix DJ012
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Jan 15, 2025
1 parent 19377a0 commit 502bbdd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
54 changes: 27 additions & 27 deletions dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements-lint.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruff==0.8.1
ruff==0.9.1

0 comments on commit 502bbdd

Please sign in to comment.