From patchwork Mon Sep 19 22:38:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 672016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sdLSz3syjz9s5w for ; Tue, 20 Sep 2016 08:40:51 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3sdLSz36RvzDsWf for ; Tue, 20 Sep 2016 08:40:51 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from BLU004-OMC3S18.hotmail.com (blu004-omc3s18.hotmail.com [65.55.116.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3sdLSK09rzzDsfc for ; Tue, 20 Sep 2016 08:40:16 +1000 (AEST) Received: from BLU437-SMTP26 ([65.55.116.72]) by BLU004-OMC3S18.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Mon, 19 Sep 2016 15:40:13 -0700 X-TMN: [JXsAXLOjzhGmy0JptaGRLdXvZtBMfzED] X-Originating-Email: [stephenfinucane@hotmail.com] Message-ID: From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 09/13] trivial: Use 'in' operator Date: Mon, 19 Sep 2016 23:38:57 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474324741-3055-1-git-send-email-stephenfinucane@hotmail.com> References: <1474324741-3055-1-git-send-email-stephenfinucane@hotmail.com> X-OriginalArrivalTime: 19 Sep 2016 22:40:10.0615 (UTC) FILETIME=[C7725870:01D212C6] MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Don't do 'x == a or x == b'. Prefer 'x in [a, b]' instead. Signed-off-by: Stephen Finucane --- 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: