From 3b7a31cec2f06cc71785d4d322d3fb7c49e985d9 Mon Sep 17 00:00:00 2001 From: Cameron Yick Date: Sat, 5 Oct 2019 20:15:17 -0400 Subject: [PATCH] [refactor] Reduce cognitive complexity from multiple return statements --- app/models.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/app/models.py b/app/models.py index c214ed9d..80a3f361 100644 --- a/app/models.py +++ b/app/models.py @@ -77,21 +77,20 @@ def key(self): return self.url def __eq__(self, other): - if isinstance(other, Resource): - if self.name != other.name: - return False - if self.url != other.url: - return False - if self.paid != other.paid: - return False - if self.notes != other.notes: - return False - if self.category != other.category: - return False - if self.languages != other.languages: - return False - return True - return False + return isinstance(other, Resource) and all( + ( + getattr(self, attribute) + == getattr(other, attribute) + for attribute in [ + "name", + "url", + "paid", + "notes", + "category", + "languages", + ] + ) + ) def __hash__(self): return hash(self.url)