Skip to content

Commit 1f488ac

Browse files
author
Aaron Suarez
authored
Merge pull request #228 from hydrosquall/refactor/reduce-code-complexity-models
[refactor] Reduce cognitive complexity from multiple return statements
2 parents e9c5020 + 3b7a31c commit 1f488ac

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

app/models.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,20 @@ def key(self):
7777
return self.url
7878

7979
def __eq__(self, other):
80-
if isinstance(other, Resource):
81-
if self.name != other.name:
82-
return False
83-
if self.url != other.url:
84-
return False
85-
if self.paid != other.paid:
86-
return False
87-
if self.notes != other.notes:
88-
return False
89-
if self.category != other.category:
90-
return False
91-
if self.languages != other.languages:
92-
return False
93-
return True
94-
return False
80+
return isinstance(other, Resource) and all(
81+
(
82+
getattr(self, attribute)
83+
== getattr(other, attribute)
84+
for attribute in [
85+
"name",
86+
"url",
87+
"paid",
88+
"notes",
89+
"category",
90+
"languages",
91+
]
92+
)
93+
)
9594

9695
def __hash__(self):
9796
return hash(self.url)

0 commit comments

Comments
 (0)