Skip to content

Commit 06b18ff

Browse files
committed
[refactor] Reduce cognitive complexity from multiple return statements
1 parent e9c5020 commit 06b18ff

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

app/models.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,22 @@ 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+
)
94+
95+
9596

9697
def __hash__(self):
9798
return hash(self.url)

0 commit comments

Comments
 (0)