[PATCH 09/13] trivial: Use 'in' operator

Stephen Finucane stephenfinucane at hotmail.com
Tue Sep 20 08:38:57 AEST 2016


Don't do 'x == a or x == b'. Prefer 'x in [a, b]' instead.

Signed-off-by: Stephen Finucane <stephenfinucane at hotmail.com>
---
 patchwork/models.py         | 2 +-
 patchwork/parser.py         | 2 +-
 patchwork/views/__init__.py | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/patchwork/models.py b/patchwork/models.py
index 4c0aa88..e067327 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -430,7 +430,7 @@ class Patch(Submission):
         if not user.is_authenticated():
             return False
 
-        if self.submitter.user == user or self.delegate == user:
+        if user in [self.submitter.user, self.delegate]:
             return True
 
         return self.project.is_editable(user)
diff --git a/patchwork/parser.py b/patchwork/parser.py
index 82f2d5e..c9b5c1e 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -473,7 +473,7 @@ def parse_patch(content):
                 state = 0
                 commentbuf += buf + line
                 buf = ''
-        elif state == 4 or state == 5:
+        elif state in [4, 5]:
             if line.startswith('-'):
                 lc[0] -= 1
             elif line.startswith('+'):
diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py
index 98e451d..944acf6 100644
--- a/patchwork/views/__init__.py
+++ b/patchwork/views/__init__.py
@@ -159,7 +159,7 @@ def set_bundle(request, project, action, data, patches, context):
         return ['no such bundle']
 
     for patch in patches:
-        if action == 'create' or action == 'add':
+        if action in ['create', 'add']:
             bundlepatch_count = BundlePatch.objects.filter(bundle=bundle,
                                                            patch=patch).count()
             if bundlepatch_count == 0:
-- 
2.7.4



More information about the Patchwork mailing list