]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
pep8: Manually resolve remaining issues
authorStephen Finucane <stephen.finucane@intel.com>
Sun, 29 Nov 2015 21:08:44 +0000 (21:08 +0000)
committerStephen Finucane <stephen.finucane@intel.com>
Thu, 3 Dec 2015 22:09:21 +0000 (22:09 +0000)
The 'autopep8' tool can't do everything, and it is necessary to resolve
some final issues. Most of these issues fall under the following
categories:

  E501  line too long
  E241  multiple spaces after ','
  F401  'module' imported but unused
  F841  local variable 'name' is assigned to but never used

It is also necessary to insert '# noqa' comments to hide some F403
errors ('unable to detect undefined names') where 'import *' is useful.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
31 files changed:
patchwork/bin/pwclient
patchwork/filters.py
patchwork/forms.py
patchwork/paginator.py
patchwork/parser.py
patchwork/requestcontext.py
patchwork/settings/dev.py
patchwork/settings/production.example.py
patchwork/templatetags/person.py
patchwork/tests/test_bundles.py
patchwork/tests/test_checks.py
patchwork/tests/test_encodings.py
patchwork/tests/test_expiry.py
patchwork/tests/test_filters.py
patchwork/tests/test_list.py
patchwork/tests/test_mboxviews.py
patchwork/tests/test_patchparser.py
patchwork/tests/test_person.py
patchwork/tests/test_registration.py
patchwork/tests/test_tags.py
patchwork/tests/test_updates.py
patchwork/tests/test_user.py
patchwork/tests/test_xmlrpc.py
patchwork/tests/utils.py
patchwork/urls.py
patchwork/utils.py
patchwork/views/__init__.py
patchwork/views/base.py
patchwork/views/bundle.py
patchwork/views/mail.py
patchwork/views/user.py

index be147e5ab630abafb9456e60f44eb5b014c41571..58f233875d918d081157a7e0dda2ae6611f99864 100755 (executable)
@@ -31,7 +31,6 @@ except ImportError:
     import xmlrpc.client as xmlrpclib
 import argparse
 import string
-import tempfile
 import subprocess
 import base64
 try:
@@ -90,7 +89,7 @@ class Filter(object):
             else:
                 self.d['state_id'] = id
 
-        if self.project != None:
+        if self.project is not None:
             id = project_id_by_name(rpc, self.project)
             if id == 0:
                 sys.stderr.write("Note: No Project found matching %s, "
@@ -112,7 +111,7 @@ class BasicHTTPAuthTransport(xmlrpclib.SafeTransport):
         xmlrpclib.SafeTransport.__init__(self)
 
     def authenticated(self):
-        return self.username != None and self.password != None
+        return self.username is not None and self.password is not None
 
     def send_host(self, connection, host):
         xmlrpclib.Transport.send_host(self, connection, host)
@@ -190,7 +189,7 @@ def list_patches(patches, format_str=None):
 def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
     filter.resolve_ids(rpc)
 
-    if submitter_str != None:
+    if submitter_str is not None:
         ids = person_ids_by_name(rpc, submitter_str)
         if len(ids) == 0:
             sys.stderr.write("Note: Nobody found matching *%s*\n" %
@@ -207,7 +206,7 @@ def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
                 list_patches(patches, format_str)
         return
 
-    if delegate_str != None:
+    if delegate_str is not None:
         ids = person_ids_by_name(rpc, delegate_str)
         if len(ids) == 0:
             sys.stderr.write("Note: Nobody found matching *%s*\n" %
@@ -551,7 +550,7 @@ def main():
         update_parser.error(
             'Must specify one or more update options (-a or -s)')
 
-    if args.get('n') != None:
+    if args.get('n') is not None:
         try:
             filt.add("max_count", args.get('n'))
         except:
@@ -631,8 +630,8 @@ def main():
                 use_https)
 
         else:
-            sys.stderr.write(("The %s action requires authentication, "
-                              "but no username or password\nis configured\n") % action)
+            sys.stderr.write("The %s action requires authentication, but no "
+                             "username or password\nis configured\n" % action)
             sys.exit(1)
 
     if project_str:
@@ -654,7 +653,7 @@ def main():
         sys.exit(1)
 
     # It should be safe to assume hash_str is not zero, but who knows..
-    if hash_str != None:
+    if hash_str is not None:
         patch_ids = [patch_id_from_hash(rpc, project_str, hash_str)]
 
     # helper for non_empty() to print correct helptext
@@ -663,16 +662,16 @@ def main():
     # Require either hash_str or IDs for
     def non_empty(h, patch_ids):
         """Error out if no patch IDs were specified"""
-        if patch_ids == None or len(patch_ids) < 1:
-            sys.stderr.write("Error: Missing Argument! " +
-                             "Either [-h HASH] or [ID [ID ...]] are required\n")
+        if patch_ids is None or len(patch_ids) < 1:
+            sys.stderr.write("Error: Missing Argument! Either [-h HASH] or "
+                             "[ID [ID ...]] are required\n")
             if h:
                 h.print_help()
             sys.exit(1)
         return patch_ids
 
     if action == 'list' or action == 'search':
-        if args.get('patch_name') != None:
+        if args.get('patch_name') is not None:
             filt.add("name__icontains", args.get('patch_name'))
         action_list(rpc, filt, submitter_str, delegate_str, format_str)
 
index 64fc6c31d590d75f14f441cedd9e403a2a734734..4ee399823fc9c236b95496ba35ea4af775aa5015 100644 (file)
@@ -68,8 +68,8 @@ class Filter(object):
 
     def form(self):
         if self.forced:
-            return mark_safe('<input type="hidden" value="%s">%s' % (self.param,
-                                                                     self.condition()))
+            return mark_safe('<input type="hidden" value="%s">%s' % (
+                self.param, self.condition()))
             return self.condition()
         return self._form()
 
@@ -201,18 +201,18 @@ class StateFilter(Filter):
         str += '<option %s value="%s">any</option>' % (selected, self.any_key)
 
         selected = ''
-        if self.applied and self.state == None:
+        if self.applied and self.state is None:
             selected = 'selected'
-        str += '<option %s value="">%s</option>' % \
-               (selected, self.action_req_str)
+        str += '<option %s value="">%s</option>' % (
+            selected, self.action_req_str)
 
         for state in State.objects.all():
             selected = ''
             if self.state and self.state == state:
                 selected = ' selected="true"'
 
-            str += '<option value="%d" %s>%s</option>' % \
-                (state.id, selected, state.name)
+            str += '<option value="%d" %s>%s</option>' % (
+                state.id, selected, state.name)
         str += '</select>'
         return mark_safe(str)
 
@@ -273,7 +273,7 @@ class ArchiveFilter(Filter):
         self.param_map = {
             True: 'true',
             False: '',
-            None:  'both'
+            None: 'both'
         }
         self.description_map = {
             True: 'Yes',
@@ -287,11 +287,11 @@ class ArchiveFilter(Filter):
         for (k, v) in self.param_map.items():
             if str == v:
                 self.archive_state = k
-        if self.archive_state == None:
+        if self.archive_state is None:
             self.applied = False
 
     def kwargs(self):
-        if self.archive_state == None:
+        if self.archive_state is None:
             return {}
         return {'archived': self.archive_state}
 
@@ -299,7 +299,7 @@ class ArchiveFilter(Filter):
         return self.description_map[self.archive_state]
 
     def key(self):
-        if self.archive_state == False:
+        if not self.archive_state:
             return None
         return self.param_map[self.archive_state]
 
@@ -346,7 +346,6 @@ class DelegateFilter(Filter):
             self.delegate = None
             return
 
-        applied = False
         try:
             self.delegate = User.objects.get(id=str)
             self.applied = True
@@ -387,8 +386,8 @@ class DelegateFilter(Filter):
             if d == self.delegate:
                 selected = ' selected'
 
-            str += '<option %s value="%s">%s</option>' % (selected,
-                                                          d.id, d.profile.name())
+            str += '<option %s value="%s">%s</option>' % (
+                selected, d.id, d.profile.name())
         str += '</select>'
 
         return mark_safe(str)
index 3b2caabfe04ae4fa49853c6ee80fc96e955538f3..c4eb8c520362c886bb265277797ca6e061e04e64 100644 (file)
@@ -37,7 +37,7 @@ class RegistrationForm(forms.Form):
     def clean_username(self):
         value = self.cleaned_data['username']
         try:
-            user = User.objects.get(username__iexact=value)
+            User.objects.get(username__iexact=value)
         except User.DoesNotExist:
             return self.cleaned_data['username']
         raise forms.ValidationError('This username is already taken. ' +
@@ -62,8 +62,9 @@ class LoginForm(forms.Form):
 
 
 class BundleForm(forms.ModelForm):
-    name = forms.RegexField(regex=r'^[^/]+$', max_length=50, label=u'Name',
-                            error_messages={'invalid': 'Bundle names can\'t contain slashes'})
+    name = forms.RegexField(
+        regex=r'^[^/]+$', max_length=50, label=u'Name',
+        error_messages={'invalid': 'Bundle names can\'t contain slashes'})
 
     class Meta:
         model = Bundle
@@ -230,7 +231,7 @@ class MultiplePatchForm(forms.Form):
         data = self.cleaned_data
         # Update the instance
         for f in opts.fields:
-            if not f.name in data:
+            if f.name not in data:
                 continue
 
             field = self.fields.get(f.name, None)
index b8c43416a7a084f975f7a095bf4f86272a14aecb..0f6d68407850f186a20874068fd320a2756a9951 100644 (file)
@@ -46,10 +46,10 @@ class Paginator(paginator.Paginator):
         if request.user.is_authenticated():
             patches_per_page = request.user.profile.patches_per_page
 
-        n = request.META.get('ppp')
-        if n:
+        ppp = request.META.get('ppp')
+        if ppp:
             try:
-                patches_per_page = int(n)
+                patches_per_page = int(ppp)
             except ValueError:
                 pass
 
@@ -67,28 +67,29 @@ class Paginator(paginator.Paginator):
         pages = self.num_pages
 
         if pages <= LEADING_PAGE_RANGE_DISPLAYED:
-            self.adjacent_set = [n for n in range(1, pages + 1)
-                                 if n > 0 and n <= pages]
+            adjacent_start = 1
+            adjacent_end = pages + 1
         elif page_no <= LEADING_PAGE_RANGE:
-            self.adjacent_set = [n for n in
-                                 range(1, LEADING_PAGE_RANGE_DISPLAYED + 1)
-                                 if n > 0 and n <= pages]
+            adjacent_start = 1
+            adjacent_end = LEADING_PAGE_RANGE_DISPLAYED + 1
             self.leading_set = [n + pages for n in
                                 range(0, -NUM_PAGES_OUTSIDE_RANGE, -1)]
         elif page_no > pages - TRAILING_PAGE_RANGE:
-            self.adjacent_set = [n for n in
-                                 range(pages - TRAILING_PAGE_RANGE_DISPLAYED + 1,
-                                       pages + 1) if n > 0 and n <= pages]
-            self.trailing_set = [n + 1 for n in range(0,
-                                                      NUM_PAGES_OUTSIDE_RANGE)]
+            adjacent_start = pages - TRAILING_PAGE_RANGE_DISPLAYED + 1
+            adjacent_end = pages + 1
+            self.trailing_set = [n + 1 for n in
+                                 range(0, NUM_PAGES_OUTSIDE_RANGE)]
         else:
-            self.adjacent_set = [n for n in range(page_no - ADJACENT_PAGES,
-                                                  page_no + ADJACENT_PAGES + 1) if n > 0 and n <= pages]
+            adjacent_start = page_no - ADJACENT_PAGES
+            adjacent_end = page_no + ADJACENT_PAGES + 1
             self.leading_set = [n + pages for n in
                                 range(0, -NUM_PAGES_OUTSIDE_RANGE, -1)]
             self.trailing_set = [n + 1 for n in
                                  range(0, NUM_PAGES_OUTSIDE_RANGE)]
 
+        self.adjacent_set = [n for n in range(adjacent_start, adjacent_end)
+                             if n > 0 and n <= pages]
+
         self.leading_set.reverse()
-        self.long_page = \
-            len(self.current_page.object_list) >= LONG_PAGE_THRESHOLD
+        self.long_page = len(
+            self.current_page.object_list) >= LONG_PAGE_THRESHOLD
index b0804ede397316b0bffe2e3c85cda2c9e496edfa..453b6e85a1251b4f9ddf5ce1d6d398d17a21690e 100644 (file)
@@ -89,7 +89,7 @@ def parse_patch(text):
             if line.startswith('--- '):
                 state = 2
 
-            if line.startswith('rename from ') or line.startswith('rename to '):
+            if line.startswith(('rename from ', 'rename to ')):
                 state = 6
 
         elif state == 2:
@@ -161,7 +161,7 @@ def parse_patch(text):
                 state = 5
 
         elif state == 6:
-            if line.startswith('rename to ') or line.startswith('rename from '):
+            if line.startswith(('rename to ', 'rename from ')):
                 patchbuf += buf + line
                 buf = ''
 
index ea327e56b39cfada0772d8eade3b09d33f98d3d3..ee26b9ba8b99ccab17479192e78ca591f43a7642 100644 (file)
@@ -22,7 +22,6 @@ from __future__ import absolute_import
 from django.conf import settings
 from django.contrib.sites.models import Site
 from django.template import RequestContext
-from django.utils.html import escape
 
 from patchwork.filters import Filters
 from patchwork.models import Bundle, Project
index c70d893e8c803bc7cdc21af718c91493cc953e4a..3ecdb066c96daaa9e408a62e6a5e4e573185f7ce 100644 (file)
@@ -11,7 +11,7 @@ from __future__ import absolute_import
 
 import django
 
-from .base import *
+from .base import *  # noqa
 
 #
 # Core settings
index b9fe38a9341dc093e8a55d98b722e3d38aa9ec51..5530bf97e33e788053fff40c4c601e42ea97214c 100644 (file)
@@ -9,7 +9,7 @@ Design based on:
 
 from __future__ import absolute_import
 
-from .base import *
+from .base import *  # noqa
 
 #
 # Core settings
index 6ea7bc4600ba85b50fb4ac2319ab7335589475e8..6829019fdb720639d8a979fff7779eedac7b2b7a 100644 (file)
@@ -19,8 +19,6 @@
 
 from __future__ import absolute_import
 
-import re
-
 from django.core.urlresolvers import reverse
 from django import template
 from django.utils.html import escape
index 4041a2fd2b29482a489929d487185b70f36458ed..958bb55494c46b2f54c5ebaea51d25a210cbec71 100644 (file)
@@ -24,7 +24,6 @@ import unittest
 
 from django.conf import settings
 from django.test import TestCase
-from django.test.client import Client
 from django.utils.http import urlencode
 
 from patchwork.models import Patch, Bundle, BundlePatch, Person
@@ -146,7 +145,7 @@ class BundleUpdateTest(BundleTestBase):
 
     def checkPatchformErrors(self, response):
         formname = 'patchform'
-        if not formname in response.context:
+        if formname not in response.context:
             return
         form = response.context[formname]
         if not form:
@@ -186,7 +185,6 @@ class BundleUpdateTest(BundleTestBase):
         self.assertEqual(bundle.public, self.bundle.public)
 
     def testUpdatePublic(self):
-        newname = 'newbundlename'
         data = {
             'form': 'bundle',
             'action': 'update',
@@ -273,7 +271,7 @@ class BundlePublicModifyTest(BundleTestBase):
         # first, check that we can modify with the owner
         self.client.login(username=self.user.username,
                           password=self.user.username)
-        response = self.client.post(bundle_url(self.bundle), data)
+        self.client.post(bundle_url(self.bundle), data)
         self.bundle = Bundle.objects.get(pk=self.bundle.pk)
         self.assertEqual(self.bundle.name, newname)
 
@@ -284,7 +282,7 @@ class BundlePublicModifyTest(BundleTestBase):
         # log in with a different user, and check that we can no longer modify
         self.client.login(username=self.other_user.username,
                           password=self.other_user.username)
-        response = self.client.post(bundle_url(self.bundle), data)
+        self.client.post(bundle_url(self.bundle), data)
         self.bundle = Bundle.objects.get(pk=self.bundle.pk)
         self.assertNotEqual(self.bundle.name, newname)
 
@@ -327,7 +325,6 @@ class BundleCreateFromListTest(BundleTestBase):
         self.assertEqual(bundle.patches.all()[0], patch)
 
     def testCreateNonEmptyBundleEmptyName(self):
-        newbundlename = 'testbundle-new'
         patch = self.patches[0]
 
         n_bundles = Bundle.objects.count()
@@ -408,10 +405,10 @@ class BundleCreateFromPatchTest(BundleTestBase):
 
         response = self.client.post('/patch/%d/' % patch.id, params)
 
-        self.assertContains(response,
-                            'A bundle called %s already exists' % newbundlename)
+        self.assertContains(
+            response,
+            'A bundle called %s already exists' % newbundlename)
 
-        count = Bundle.objects.count()
         self.assertEqual(Bundle.objects.count(), 1)
 
 
@@ -514,9 +511,10 @@ class BundleAddFromPatchTest(BundleTestBase):
 
         response = self.client.post('/patch/%d/' % patch.id, params)
 
-        self.assertContains(response,
-                            'added to bundle &quot;%s&quot;' % self.bundle.name,
-                            count=1)
+        self.assertContains(
+            response,
+            'added to bundle &quot;%s&quot;' % self.bundle.name,
+            count=1)
 
         self.assertEqual(self.bundle.patches.count(), 1)
         self.assertEqual(self.bundle.patches.all()[0], patch)
@@ -529,9 +527,10 @@ class BundleAddFromPatchTest(BundleTestBase):
 
         response = self.client.post('/patch/%d/' % patch.id, params)
 
-        self.assertContains(response,
-                            'added to bundle &quot;%s&quot;' % self.bundle.name,
-                            count=1)
+        self.assertContains(
+            response,
+            'added to bundle &quot;%s&quot;' % self.bundle.name,
+            count=1)
 
         self.assertEqual(self.bundle.patches.count(), 2)
         self.assertIn(self.patches[0], self.bundle.patches.all())
index e75b258185d9c1e4df662d78f10403d18cf83ff9..4711b4adf36bf1039441ce8482e7ec5152806d15 100644 (file)
@@ -20,8 +20,6 @@
 from datetime import datetime as dt
 from datetime import timedelta
 
-from django.conf import settings
-from django.db import connection
 from django.test import TransactionTestCase
 
 from patchwork.models import Patch, Check
@@ -105,13 +103,13 @@ class PatchChecksTest(TransactionTestCase):
         self.assertChecksEqual(self.patch, [check_a, check_b])
 
     def test_checks__duplicate_checks(self):
-        check_a = self.create_check(date=(dt.now() - timedelta(days=1)))
-        check_b = self.create_check()
+        self.create_check(date=(dt.now() - timedelta(days=1)))
+        check = self.create_check()
         # this isn't a realistic scenario (dates shouldn't be set by user so
         #   they will always increment), but it's useful to verify the removal
         #   of older duplicates by the function
-        check_c = self.create_check(date=(dt.now() - timedelta(days=2)))
-        self.assertChecksEqual(self.patch, [check_b])
+        self.create_check(date=(dt.now() - timedelta(days=2)))
+        self.assertChecksEqual(self.patch, [check])
 
     def test_check_count__no_checks(self):
         self.assertCheckCountEqual(self.patch, 0)
index 575ef35403a106b4cbeecd147a52aeffb5cd5c42..e39e31940b7ba67f98c1fe25751f66aa577ae543 100644 (file)
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import os
-import time
-import unittest
-
 from django.test.client import Client
 from django.test import TestCase
 
index 2f8758e51057ba40b3acf4805288bcb8ec43d69c..a0596dc21a30201ff767ad92e99d1b3ad084d8ef 100644 (file)
@@ -18,7 +18,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 import datetime
-import unittest
 
 from django.contrib.auth.models import User
 from django.test import TestCase
@@ -95,8 +94,9 @@ class TestRegistrationExpiry(TestCase):
         date = ((datetime.datetime.now() - EmailConfirmation.validity) -
                 datetime.timedelta(hours=1))
         userid = 'test-user'
-        user = User.objects.create_user(userid,
-                                        defaults.patch_author_person.email, userid)
+        user = User.objects.create_user(
+            userid,
+            defaults.patch_author_person.email, userid)
         user.is_active = False
         user.date_joined = user.last_login = date
         user.save()
index a4014b6df75107e6ea6aef2b6908c859974ac65a..72a85cedff33c79fe40b13d9174738e502693d13 100644 (file)
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import unittest
-
 from django.test import TestCase
-from django.test.client import Client
 
-from patchwork.tests.utils import defaults, create_user, find_in_context
+from patchwork.tests.utils import defaults
 
 
 class FilterQueryStringTest(TestCase):
index a9320dfe31ed9cbb26559b641ef48b1e48ab887c..886285805247ab4d76abb9d2344d54fb5e6082ac 100644 (file)
 from __future__ import absolute_import
 
 import datetime
-import random
 import re
-import string
-import unittest
 
 from django.core.urlresolvers import reverse
-from django.test.client import Client
 from django.test import TestCase
 from django.utils.six.moves import zip
 
 from patchwork.models import Person, Patch
-from patchwork.tests.utils import defaults, create_user, find_in_context
+from patchwork.tests.utils import defaults
 
 
 class EmptyPatchListTest(TestCase):
index 0e16c0bbce04a7f08f7122017c8f62689631fdb3..9c82531215dde0d4002c8a7b1f7b97cd08924285 100644 (file)
@@ -23,13 +23,11 @@ import datetime
 import dateutil.parser
 import dateutil.tz
 import email
-import unittest
 
-from django.test.client import Client
 from django.test import TestCase
 
-from patchwork.models import Patch, Comment, Person
-from patchwork.tests.utils import defaults, create_user, find_in_context
+from patchwork.models import Patch, Comment
+from patchwork.tests.utils import defaults
 
 
 class MboxPatchResponseTest(TestCase):
index bc3dfdce50777d2767dbbebf35e5f0a554447fe0..e526a79db4b116502316f976d8737df3cced604f 100644 (file)
@@ -20,7 +20,6 @@
 from email import message_from_string
 from email.mime.text import MIMEText
 from email.utils import make_msgid
-import os
 
 from django.test import TestCase
 
@@ -308,8 +307,8 @@ class MultipleProjectPatchTest(TestCase):
 
 class MultipleProjectPatchCommentTest(MultipleProjectPatchTest):
 
-    """ Test that followups to multiple-project patches end up on the
-        correct patch """
+    """Test that followups to multiple-project patches end up on the
+       correct patch."""
 
     comment_msgid = '<2@example.com>'
     comment_content = 'test comment'
@@ -329,18 +328,19 @@ class MultipleProjectPatchCommentTest(MultipleProjectPatchTest):
     def testParsedComment(self):
         for project in [self.p1, self.p2]:
             patch = Patch.objects.filter(project=project)[0]
-            # we should see two comments now - the original mail with the patch,
-            # and the one we parsed in setUp()
+            # we should see two comments now - the original mail with the
+            # patch, and the one we parsed in setUp()
             self.assertEqual(Comment.objects.filter(patch=patch).count(), 2)
 
 
 class ListIdHeaderTest(TestCase):
 
-    """ Test that we parse List-Id headers from mails correctly """
+    """Test that we parse List-Id headers from mails correctly."""
 
     def setUp(self):
         self.project = Project(linkname='test-project-1', name='Project 1',
-                               listid='1.example.com', listemail='1@example.com')
+                               listid='1.example.com',
+                               listemail='1@example.com')
         self.project.save()
 
     def testNoListId(self):
@@ -411,8 +411,9 @@ class GitPullWithDiffTest(MBoxPatchTest):
     def testGitPullWithDiff(self):
         (patch, comment) = find_content(self.project, self.mail)
         self.assertTrue(patch is not None)
-        self.assertEqual('git://git.kernel.org/pub/scm/linux/kernel/git/tip/' +
-                         'linux-2.6-tip.git x86-fixes-for-linus', patch.pull_url)
+        self.assertEqual('git://git.kernel.org/pub/scm/linux/kernel/git/tip/'
+                         'linux-2.6-tip.git x86-fixes-for-linus',
+                         patch.pull_url)
         self.assertTrue(
             patch.content.startswith(
                 'diff --git a/arch/x86/include/asm/smp.h'),
index 6ced981ba2c60465226d7e39ad7cb69f7d6bd552..ba00457d8654bf89f4215621691b2416f1518918 100644 (file)
 from __future__ import absolute_import
 
 import json
-import unittest
-
-from django.test.client import Client
 from django.test import TestCase
 from django.utils.six.moves import map, range
 
-from patchwork.models import EmailConfirmation, Person, Bundle
+from patchwork.models import Person
 
 
 class SubmitterCompletionTest(TestCase):
index 296d21fea2808ad44430938dddc00e73eaa7b803..b5eacef568fec50f119de3c6bc1a5f30cfd88d33 100644 (file)
@@ -17,8 +17,6 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import unittest
-
 from django.contrib.auth.models import User
 from django.core import mail
 from django.core.urlresolvers import reverse
@@ -81,7 +79,8 @@ class RegistrationTest(TestCase):
         response = self.client.post('/register/', data)
         self.assertEqual(response.status_code, 200)
         self.assertFormError(response, 'form', 'username',
-                             'This username is already taken. Please choose another.')
+                             'This username is already taken. Please choose '
+                             'another.')
 
     def testExistingEmail(self):
         user = create_user()
@@ -90,7 +89,7 @@ class RegistrationTest(TestCase):
         response = self.client.post('/register/', data)
         self.assertEqual(response.status_code, 200)
         self.assertFormError(response, 'form', 'email',
-                             'This email address is already in use ' +
+                             'This email address is already in use '
                              'for the account "%s".\n' % user.username)
 
     def testValidRegistration(self):
index 84eda9c2a6b6b230c44e0094250d6e64826aa373..70ca43d64b6c8b2d92d6f74593575da9aadd626f 100644 (file)
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 import datetime
-import unittest
 
 from django.conf import settings
-from django.db import connection
 from django.test import TestCase, TransactionTestCase
 
 from patchwork.models import Project, Patch, Comment, Tag, PatchTag
index 819a39f9e1d47f4ffada21da6cc66de918978db0..a8d9749b6c7c51365f9e47f0d54bb2b2b90f4bc6 100644 (file)
@@ -112,11 +112,11 @@ class MultipleUpdateTest(TestCase):
 
     def testDelegateChangeValid(self):
         delegate = create_maintainer(defaults.project)
-        response = self._testDelegateChange(str(delegate.pk))
+        self._testDelegateChange(str(delegate.pk))
         for p in self.patches:
             self.assertEqual(Patch.objects.get(pk=p.pk).delegate, delegate)
 
     def testDelegateClear(self):
-        response = self._testDelegateChange('')
+        self._testDelegateChange('')
         for p in self.patches:
             self.assertEqual(Patch.objects.get(pk=p.pk).delegate, None)
index 642781e2649a6f370be85d6384c843d2f53e5a9d..e9d182278c037bf214a00592f7d14f684542942c 100644 (file)
@@ -167,7 +167,7 @@ class UserProfileTest(TestCase):
         old_ppp = user_profile.patches_per_page
         new_ppp = old_ppp + 1
 
-        response = self.client.post('/user/', {'patches_per_page': new_ppp})
+        self.client.post('/user/', {'patches_per_page': new_ppp})
 
         user_profile = UserProfile.objects.get(user=self.user.user.id)
         self.assertEqual(user_profile.patches_per_page, new_ppp)
@@ -177,7 +177,7 @@ class UserProfileTest(TestCase):
         old_ppp = user_profile.patches_per_page
         new_ppp = -1
 
-        response = self.client.post('/user/', {'patches_per_page': new_ppp})
+        self.client.post('/user/', {'patches_per_page': new_ppp})
 
         user_profile = UserProfile.objects.get(user=self.user.user.id)
         self.assertEqual(user_profile.patches_per_page, old_ppp)
index 960b994c11d2effd200cc0ca29cf08bd716fa13a..d8c77f066274e080d2721de962a70ed008205657 100644 (file)
@@ -24,12 +24,13 @@ from django.core.urlresolvers import reverse
 from django.test import LiveServerTestCase
 from django.utils.six.moves import xmlrpc_client
 
-from patchwork.models import Person, Patch
+from patchwork.models import Patch
 from patchwork.tests.utils import defaults
 
 
 @unittest.skipUnless(settings.ENABLE_XMLRPC,
-                     "requires xmlrpc interface (use the ENABLE_XMLRPC setting)")
+                     'requires xmlrpc interface (use the ENABLE_XMLRPC '
+                     'setting)')
 class XMLRPCTest(LiveServerTestCase):
     fixtures = ['default_states']
 
index 1f57351916854e12d2d61fb6048c4fe53baee54b..04250a8cdad88e5af3f9ee772e3854644bbc7c18 100644 (file)
@@ -25,7 +25,6 @@ from email.utils import make_msgid
 import os
 
 from django.contrib.auth.models import User
-from django.forms.fields import EmailField
 
 from patchwork.models import Project, Person
 
index b0cc2997184061e0c1944ce6432f09d324a443fe..81a571a10bc815f13286ede18fd34429d36e594d 100644 (file)
@@ -43,8 +43,7 @@ urlpatterns = patterns(
     (r'^user/todo/$', 'patchwork.views.user.todo_lists'),
     (r'^user/todo/(?P<project_id>[^/]+)/$', 'patchwork.views.user.todo_list'),
 
-    (r'^user/bundles/$',
-        'patchwork.views.bundle.bundles'),
+    (r'^user/bundles/$', 'patchwork.views.bundle.bundles'),
 
     (r'^user/link/$', 'patchwork.views.user.link'),
     (r'^user/unlink/(?P<person_id>[^/]+)/$', 'patchwork.views.user.unlink'),
@@ -111,7 +110,7 @@ if settings.COMPAT_REDIR:
     urlpatterns += patterns(
         '',
         (r'^user/bundle/(?P<bundle_id>[^/]+)/$',
-            'patchwork.views.bundle.bundle_redir'),
+         'patchwork.views.bundle.bundle_redir'),
         (r'^user/bundle/(?P<bundle_id>[^/]+)/mbox/$',
-            'patchwork.views.bundle.mbox_redir'),
+         'patchwork.views.bundle.mbox_redir'),
     )
index bcb1e8d985b4723d9e2e541c447d3e67ad006197..0b6594d45a3945789a2bc313069711b813c96857 100644 (file)
@@ -27,13 +27,11 @@ from django.contrib.auth.models import User
 from django.contrib.sites.models import Site
 from django.core.mail import EmailMessage
 from django.db.models import Max, Q, F
-from django.db.utils import IntegrityError
 from django.shortcuts import get_object_or_404
 from django.template.loader import render_to_string
 
-from patchwork.models import (Bundle, Project, BundlePatch, UserProfile,
-                              PatchChangeNotification, EmailOptout,
-                              EmailConfirmation)
+from patchwork.models import (Bundle, BundlePatch, PatchChangeNotification,
+                              EmailOptout, EmailConfirmation)
 
 
 def get_patch_ids(d, prefix='patch_id'):
@@ -54,11 +52,11 @@ def get_patch_ids(d, prefix='patch_id'):
 
 class Order(object):
     order_map = {
-        'date':         'date',
-        'name':         'name',
-        'state':        'state__ordering',
-        'submitter':    'submitter__name',
-        'delegate':     'delegate__username',
+        'date': 'date',
+        'name': 'name',
+        'state': 'state__ordering',
+        'submitter': 'submitter__name',
+        'delegate': 'delegate__username',
     }
     default_order = ('date', True)
 
@@ -180,18 +178,17 @@ def set_bundle(user, project, action, data, patches, context):
 
 
 def send_notifications():
-    date_limit = datetime.datetime.now() - \
-        datetime.timedelta(minutes=settings.NOTIFICATION_DELAY_MINUTES)
+    date_limit = datetime.datetime.now() - datetime.timedelta(
+        minutes=settings.NOTIFICATION_DELAY_MINUTES)
 
     # This gets funky: we want to filter out any notifications that should
     # be grouped with other notifications that aren't ready to go out yet. To
     # do that, we join back onto PatchChangeNotification (PCN -> Patch ->
     # Person -> Patch -> max(PCN.last_modified)), filtering out any maxima
     # that are with the date_limit.
-    qs = PatchChangeNotification.objects \
-        .annotate(m=Max('patch__submitter__patch__patchchangenotification'
-                        '__last_modified')) \
-        .filter(m__lt=date_limit)
+    qs = PatchChangeNotification.objects.annotate(
+        m=Max('patch__submitter__patch__patchchangenotification'
+              '__last_modified')).filter(m__lt=date_limit)
 
     groups = itertools.groupby(qs.order_by('patch__submitter'),
                                lambda n: n.patch.submitter)
@@ -230,7 +227,7 @@ def send_notifications():
 
         try:
             message.send()
-        except ex:
+        except Exception as ex:
             errors.append((recipient, ex))
             continue
 
@@ -247,12 +244,9 @@ def do_expiry():
 
     # expire inactive users with no pending confirmation
     pending_confs = EmailConfirmation.objects.values('user')
-    users = User.objects.filter(
-        is_active=False,
-        last_login=F('date_joined')
-    ).exclude(
-        id__in=pending_confs
-    )
+    users = User.objects.filter(is_active=False,
+                                last_login=F('date_joined')).exclude(
+                                    id__in=pending_confs)
 
     # delete users
     users.delete()
index 0386a7991668b422be01f6f90a9025af5cdfa26a..bf6cad150430dda91d4bc7be3c77daa1ccc965f3 100644 (file)
@@ -27,11 +27,11 @@ from email.parser import HeaderParser
 import email.utils
 import re
 
-from .base import *
+from .base import *  # noqa
 from patchwork.utils import Order, get_patch_ids, bundle_actions, set_bundle
 from patchwork.paginator import Paginator
 from patchwork.forms import MultiplePatchForm
-from patchwork.models import Comment
+from patchwork.models import Comment, Patch
 
 
 def generic_list(request, project, view,
@@ -119,10 +119,10 @@ def generic_list(request, project, view,
     paginator = Paginator(request, patches)
 
     context.update({
-        'page':             paginator.current_page,
-        'patchform':        properties_form,
-        'project':          project,
-        'order':            order,
+        'page': paginator.current_page,
+        'patchform': properties_form,
+        'project': project,
+        'order': order,
     })
 
     return context
index 1488550818667a3729e9ad8984742cd8257c59ad..cd9c43f036617016079e17118a55bc752cf1f8a1 100644 (file)
@@ -28,7 +28,7 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404
 from django.shortcuts import render_to_response, get_object_or_404
 from django.template.loader import render_to_string
 
-from patchwork.models import Patch, Project, Person, EmailConfirmation
+from patchwork.models import Project, Person, EmailConfirmation
 from patchwork.requestcontext import PatchworkRequestContext
 
 
@@ -122,8 +122,8 @@ def submitter_complete(request):
 
     return HttpResponse(json.dumps(data), content_type="application/json")
 
-help_pages = {'':           'index.html',
-              'about/':     'about.html',
+help_pages = {'': 'index.html',
+              'about/': 'about.html',
               }
 
 if settings.ENABLE_XMLRPC:
@@ -133,5 +133,6 @@ if settings.ENABLE_XMLRPC:
 def help(request, path):
     context = PatchworkRequestContext(request)
     if path in help_pages:
-        return render_to_response('patchwork/help/' + help_pages[path], context)
+        return render_to_response(
+            'patchwork/help/' + help_pages[path], context)
     raise Http404
index 3ae9f6ef0c47f4067470c9689ed8fae5f8d2b72e..04067ffccac06965806276009bb1cf8c5f417cf8 100644 (file)
@@ -20,9 +20,9 @@
 from __future__ import absolute_import
 
 from django.contrib.auth.decorators import login_required
-from django.contrib.auth.models import User
 import django.core.urlresolvers
-from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
+from django.http import (HttpResponse, HttpResponseRedirect,
+                         HttpResponseNotFound)
 from django.shortcuts import render_to_response, get_object_or_404
 
 from patchwork.filters import DelegateFilter
@@ -59,7 +59,8 @@ def setbundle(request):
             bundle.save()
         elif action == 'add':
             bundle = get_object_or_404(Bundle,
-                                       owner=request.user, id=request.POST['id'])
+                                       owner=request.user,
+                                       id=request.POST['id'])
             bundle.save()
 
             patch_id = request.get('patch_id', None)
@@ -165,14 +166,17 @@ def bundle(request, username, bundlename):
         else:
             form = BundleForm(instance=bundle)
 
-        if request.method == 'POST' and \
-                request.POST.get('form') == 'reorderform':
-            order = get_object_or_404(BundlePatch, bundle=bundle,
-                                      patch__id=request.POST.get('order_start')).order
+        if (request.method == 'POST' and
+            request.POST.get('form') == 'reorderform'):
+            order = get_object_or_404(
+                BundlePatch,
+                bundle=bundle,
+                patch__id=request.POST.get('order_start')).order
 
             for patch_id in request.POST.getlist('neworder'):
                 bundlepatch = get_object_or_404(BundlePatch,
-                                                bundle=bundle, patch__id=patch_id)
+                                                bundle=bundle,
+                                                patch__id=patch_id)
                 bundlepatch.order = order
                 bundlepatch.save()
                 order += 1
index 10b842d435980aaf2f7c46018a49f09343c6e952..6336af66f1791089b08e3995606183760acb4e84 100644 (file)
@@ -112,9 +112,9 @@ def optinout(request, action, description):
                   conf_settings.DEFAULT_FROM_EMAIL, [email])
         context['email'] = mail
         context['email_sent'] = True
-    except Exception as ex:
-        context['error'] = 'An error occurred during confirmation . ' + \
-                           'Please try again later.'
+    except Exception:
+        context['error'] = ('An error occurred during confirmation . '
+                            'Please try again later.')
         context['admins'] = conf_settings.ADMINS
 
     return render_to_response(html_template, context)
index 443545d1a1190fc12dbdaaa9488cbddf4b63840b..529a3bd30985da8b107c0c4571a89655b9fbc060 100644 (file)
@@ -62,8 +62,9 @@ def register(request):
             mail_ctx = {'site': Site.objects.get_current(),
                         'confirmation': conf}
 
-            subject = render_to_string('patchwork/activation_email_subject.txt',
-                                       mail_ctx).replace('\n', ' ').strip()
+            subject = render_to_string(
+                'patchwork/activation_email_subject.txt',
+                mail_ctx).replace('\n', ' ').strip()
 
             message = render_to_string('patchwork/activation_email.txt',
                                        mail_ctx)