Commit 2a4a395a authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

PEP8: Massage the code into conformance

A lot of minor changes.

W504 is getting ignored, as we break the line after the binary operator
throughout the code base (alternative would be W503 - break before the
operator).
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 142e8fab
......@@ -761,7 +761,7 @@ class GitPatchwork(object):
try:
with open(ts_filename) as ts_file:
since = ts_file.read()
except IOError as e:
except IOError:
pass
if self.cmd.since:
......
......@@ -296,7 +296,7 @@ class PatchManager(models.Manager):
def filename(name, ext):
fname_re = re.compile('[^-_A-Za-z0-9\.]+')
fname_re = re.compile(r'[^-_A-Za-z0-9\.]+')
str = fname_re.sub('-', name)
return str.strip('-') + ext
......
......@@ -29,8 +29,8 @@ import re
from django.utils.six.moves import map
_hunk_re = re.compile('^\@\@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? \@\@')
_filename_re = re.compile('^(---|\+\+\+) (\S+)')
_hunk_re = re.compile(r'^\@\@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? \@\@')
_filename_re = re.compile(r'^(---|\+\+\+) (\S+)')
def parse_patch(text):
......@@ -126,7 +126,7 @@ def parse_patch(text):
buf = ''
state = 2
elif hunk and line.startswith('\ No newline at end of file'):
elif hunk and line.startswith('\\ No newline at end of file'):
# If we had a hunk and now we see this, it's part of the patch,
# and we're still expecting another @@ line.
patchbuf += line
......@@ -145,7 +145,7 @@ def parse_patch(text):
lc[0] -= 1
elif line.startswith('+'):
lc[1] -= 1
elif line.startswith('\ No newline at end of file'):
elif line.startswith('\\ No newline at end of file'):
# Special case: Not included as part of the hunk's line count
pass
else:
......
......@@ -36,23 +36,23 @@ def _compile(t):
_patch_span_res = list(map(_compile, [
('^(Index:?|diff|\-\-\-|\+\+\+|\*\*\*) .*$', 'p_header'),
('^\+.*$', 'p_add'),
('^-.*$', 'p_del'),
('^!.*$', 'p_mod'),
(r'^(Index:?|diff|\-\-\-|\+\+\+|\*\*\*) .*$', 'p_header'),
(r'^\+.*$', 'p_add'),
(r'^-.*$', 'p_del'),
(r'^!.*$', 'p_mod'),
]))
_patch_chunk_re = \
re.compile('^(@@ \-\d+(?:,\d+)? \+\d+(?:,\d+)? @@)(.*)$', re.M | re.I)
re.compile(r'^(@@ \-\d+(?:,\d+)? \+\d+(?:,\d+)? @@)(.*)$', re.M | re.I)
_comment_span_res = list(map(_compile, [
('^\s*Signed-off-by: .*$', 'signed-off-by'),
('^\s*Acked-by: .*$', 'acked-by'),
('^\s*Nacked-by: .*$', 'nacked-by'),
('^\s*Tested-by: .*$', 'tested-by'),
('^\s*Reviewed-by: .*$', 'reviewed-by'),
('^\s*From: .*$', 'from'),
('^\s*&gt;.*$', 'quote'),
(r'^\s*Signed-off-by: .*$', 'signed-off-by'),
(r'^\s*Acked-by: .*$', 'acked-by'),
(r'^\s*Nacked-by: .*$', 'nacked-by'),
(r'^\s*Tested-by: .*$', 'tested-by'),
(r'^\s*Reviewed-by: .*$', 'reviewed-by'),
(r'^\s*From: .*$', 'from'),
(r'^\s*&gt;.*$', 'quote'),
]))
_span = '<span class="%s">%s</span>'
......
......@@ -91,7 +91,7 @@ class PatchOrderTest(TestCase):
patch.save()
def _extract_patch_ids(self, response):
id_re = re.compile('<tr id="patch_row:(\d+)"')
id_re = re.compile(r'<tr id="patch_row:(\d+)"')
ids = [int(m.group(1))
for m in id_re.finditer(response.content.decode())]
return ids
......
......@@ -258,9 +258,9 @@ class UserProfileOptoutFormTest(TestCase):
self.url = reverse('user')
self.optout_url = reverse('mail_optout')
self.optin_url = reverse('mail_optin')
self.form_re_template = ('<form\s+[^>]*action="%(url)s"[^>]*>'
'.*?<input\s+[^>]*value="%(email)s"[^>]*>.*?'
'</form>')
self.form_re_template = (r'<form\s+[^>]*action="%(url)s"[^>]*>'
r'.*?<input\s+[^>]*value="%(email)s"[^>]*>.*?'
r'</form>')
self.secondary_email = 'test2@example.com'
self.user = create_user()
......
......@@ -657,12 +657,13 @@ class NoNewlineAtEndOfFilePatchTest(MBoxPatchTest):
'diff --git a/tools/testing/selftests/powerpc/Makefile'))
# Confirm the trailing no newline marker doesn't end up in the comment
self.assertFalse(comment.content.rstrip().endswith(
'\ No newline at end of file'))
'\\ No newline at end of file'))
# Confirm it's instead at the bottom of the patch
self.assertTrue(patch.content.rstrip().endswith(
'\ No newline at end of file'))
'\\ No newline at end of file'))
# Confirm we got both markers
self.assertEqual(2, patch.content.count('\ No newline at end of file'))
self.assertEqual(2,
patch.content.count('\\ No newline at end of file'))
class DelegateRequestTest(TestCase):
......
......@@ -23,7 +23,7 @@ deps = flake8
commands = flake8 {posargs:patchwork patchwork/bin/pwclient git-pw/git-pw}
[flake8]
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E203,E241,E251,E402,H405,F405
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E203,E241,E251,E402,H405,F405,W504
exclude = ./patchwork/migrations
[testenv:lint]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment