From cf7934974e60d9e7aafe6e761d64e2bed1574d41 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Fri, 21 Feb 2020 12:20:44 +0000 Subject: [PATCH] Swap to pycodestyle rather than pep8 in Travis And eliminate W605 errors --- .travis.yml | 2 +- RIGS/finance.py | 2 +- RIGS/rigboard.py | 4 ++-- RIGS/signals.py | 2 +- RIGS/test_functional.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2527c43..7195332a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_script: - python manage.py collectstatic --noinput script: - - pep8 . --exclude=migrations,importer* + - pycodestyle . --exclude=migrations,importer* - python manage.py check - python manage.py makemigrations --check --dry-run - coverage run manage.py test --verbosity=2 diff --git a/RIGS/finance.py b/RIGS/finance.py index b64b2e71..a7c357fb 100644 --- a/RIGS/finance.py +++ b/RIGS/finance.py @@ -76,7 +76,7 @@ class InvoicePrint(generic.View): pdfData = buffer.read() - escapedEventName = re.sub('[^a-zA-Z0-9 \n\.]', '', object.name) + escapedEventName = re.sub(r'[^a-zA-Z0-9 \n\.]', '', object.name) response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = "filename=Invoice %05d - N%05d | %s.pdf" % (invoice.pk, invoice.event.pk, escapedEventName) diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index d91fc222..664cbe56 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -110,7 +110,7 @@ class EventCreate(generic.CreateView): context['currentVAT'] = models.VatRate.objects.current_rate() form = context['form'] - if re.search('"-\d+"', form['items_json'].value()): + if re.search(r'"-\d+"', form['items_json'].value()): messages.info(self.request, "Your item changes have been saved. Please fix the errors and save the event.") # Get some other objects to include in the form. Used when there are errors but also nice and quick. @@ -218,7 +218,7 @@ class EventPrint(generic.View): response = HttpResponse(content_type='application/pdf') - escapedEventName = re.sub('[^a-zA-Z0-9 \n\.]', '', object.name) + escapedEventName = re.sub(r'[^a-zA-Z0-9 \n\.]', '', object.name) response['Content-Disposition'] = "filename=N%05d | %s.pdf" % (object.pk, escapedEventName) response.write(merged.getvalue()) diff --git a/RIGS/signals.py b/RIGS/signals.py index ea0395d7..f0e8308b 100644 --- a/RIGS/signals.py +++ b/RIGS/signals.py @@ -69,7 +69,7 @@ def send_eventauthorisation_success_email(instance): external_styles=css).transform() client_email.attach_alternative(html, 'text/html') - escapedEventName = re.sub('[^a-zA-Z0-9 \n\.]', '', instance.event.name) + escapedEventName = re.sub(r'[^a-zA-Z0-9 \n\.]', '', instance.event.name) client_email.attach('N%05d - %s - CONFIRMATION.pdf' % (instance.event.pk, escapedEventName), merged.getvalue(), diff --git a/RIGS/test_functional.py b/RIGS/test_functional.py index 7ab1ff0f..7ff1ea19 100644 --- a/RIGS/test_functional.py +++ b/RIGS/test_functional.py @@ -122,7 +122,7 @@ class UserRegistrationTest(LiveServerTestCase): email = mail.outbox[0] self.assertIn('John Smith "JS" activation required', email.subject) urls = re.findall( - 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', email.body) + r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', email.body) self.assertEqual(len(urls), 1) mail.outbox = [] # empty this for later