Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff: Fix DJ012 #11543

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading