Skip to content

Commit 1fd7e65

Browse files
fix: validating the code using ruff
Signed-off-by: AbanoubAziz <[email protected]>
1 parent a3be1fb commit 1fd7e65

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

scanpipe/models.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import shutil
2828
import uuid
2929
from collections import Counter
30-
from collections import deque
3130
from collections import defaultdict
31+
from collections import deque
3232
from contextlib import suppress
3333
from itertools import groupby
3434
from operator import itemgetter
@@ -2876,22 +2876,22 @@ def descendants(self):
28762876
"""
28772877
return self.project.codebaseresources.filter(path__startswith=f"{self.path}/")
28782878

2879-
def ancestors(self):
2880-
"""
2881-
Return a QuerySet of ancestors CodebaseResource objects using a database query
2882-
on the current CodebaseResource `path`. The current CodebaseResource is not included
2883-
"""
2884-
2885-
if not self.has_parent():
2886-
return []
2887-
anscesotrs = deque()
2888-
current = self.parent()
2889-
anscesotrs_appendleft = anscesotrs.appendleft
2890-
2891-
while current:
2892-
anscesotrs_appendleft(current)
2893-
current = current.parent()
2894-
2879+
def ancestors(self):
2880+
"""
2881+
Return a QuerySet of ancestors CodebaseResource objects using a database query
2882+
on the current CodebaseResource `path`. The current CodebaseResource is not
2883+
included
2884+
"""
2885+
if not self.has_parent():
2886+
return []
2887+
anscesotrs = deque()
2888+
current = self.parent()
2889+
anscesotrs_appendleft = anscesotrs.appendleft
2890+
2891+
while current:
2892+
anscesotrs_appendleft(current)
2893+
current = current.parent()
2894+
28952895
return list(anscesotrs)
28962896

28972897
def children(self, codebase=None):

scanpipe/tests/test_models.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -1905,17 +1905,17 @@ def test_scanpipe_codebase_resource_descendants(self):
19051905
"asgiref-3.3.0-py3-none-any.whl-extract/asgiref/wsgi.py",
19061906
]
19071907
self.assertEqual(expected, sorted([resource.path for resource in descendants]))
1908-
1909-
def test_scanpipe_codebase_resource_ancestors(self):
1910-
path = "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/__init__.py"
1911-
resource = self.project_asgiref.codebaseresources.get(path=path)
1912-
ancestors = list(resource.ancestors())
1913-
self.assertEqual(2, len(ancestors))
1914-
self.assertNotIn(resource.path, ancestors)
1915-
expected = [
1916-
"asgiref-3.3.0-py3-none-any.whl-extract",
1917-
"asgiref-3.3.0-py3-none-any.whl-extract/asgiref",
1918-
]
1908+
1909+
def test_scanpipe_codebase_resource_ancestors(self):
1910+
path = "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/__init__.py"
1911+
resource = self.project_asgiref.codebaseresources.get(path=path)
1912+
ancestors = list(resource.ancestors())
1913+
self.assertEqual(2, len(ancestors))
1914+
self.assertNotIn(resource.path, ancestors)
1915+
expected = [
1916+
"asgiref-3.3.0-py3-none-any.whl-extract",
1917+
"asgiref-3.3.0-py3-none-any.whl-extract/asgiref",
1918+
]
19191919
self.assertEqual(expected, [resource.path for resource in ancestors])
19201920

19211921
def test_scanpipe_codebase_resource_children(self):

0 commit comments

Comments
 (0)