[PATCH 10/13] trivial: Combine if statements
Stephen Finucane
stephenfinucane at hotmail.com
Tue Sep 20 08:38:58 AEST 2016
Signed-off-by: Stephen Finucane <stephenfinucane at hotmail.com>
---
patchwork/filters.py | 5 ++---
patchwork/views/user.py | 7 +++----
patchwork/views/xmlrpc.py | 7 +++----
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/patchwork/filters.py b/patchwork/filters.py
index bea4340..4d6eab9 100644
--- a/patchwork/filters.py
+++ b/patchwork/filters.py
@@ -440,9 +440,8 @@ class Filters:
if k not in params:
params[k] = v
- if remove is not None:
- if remove.param in list(params.keys()):
- del params[remove.param]
+ if remove and remove.param in list(params.keys()):
+ del params[remove.param]
def sanitise(s):
if not isinstance(s, six.string_types):
diff --git a/patchwork/views/user.py b/patchwork/views/user.py
index 84896bd..691a4f9 100644
--- a/patchwork/views/user.py
+++ b/patchwork/views/user.py
@@ -184,10 +184,9 @@ def link_confirm(request, conf):
def unlink(request, person_id):
person = get_object_or_404(Person, id=person_id)
- if request.method == 'POST':
- if person.email != request.user.email:
- person.user = None
- person.save()
+ if request.method == 'POST' and person.email != request.user.email:
+ person.user = None
+ person.save()
return HttpResponseRedirect(urlresolvers.reverse('user-profile'))
diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py
index 793e82a..7017cd9 100644
--- a/patchwork/views/xmlrpc.py
+++ b/patchwork/views/xmlrpc.py
@@ -587,10 +587,9 @@ def patch_list(filt=None):
if parts[0] not in ok_fields:
# Invalid field given
return []
- if len(parts) > 1:
- if LOOKUP_TYPES.count(parts[1]) == 0:
- # Invalid lookup type given
- return []
+ if len(parts) > 1 and LOOKUP_TYPES.count(parts[1]) == 0:
+ # Invalid lookup type given
+ return []
try:
if parts[0] == 'project_id':
--
2.7.4
More information about the Patchwork
mailing list