add flake8 and fix a few formatting bugs

pull/254/head
Tobias McNulty 2019-09-12 08:07:42 -04:00 zatwierdzone przez Matt Westcott
rodzic cab9e25474
commit 7ee23ded4c
9 zmienionych plików z 23 dodań i 18 usunięć

Wyświetl plik

@ -17,6 +17,7 @@ script:
- timeout $GREP_TIMEOUT grep -m 1 'Running migrations' <(docker-compose logs --follow app 2>&1)
- timeout $GREP_TIMEOUT grep -m 1 'spawned uWSGI http 1' <(docker-compose logs --follow app 2>&1)
- docker-compose run app /bin/sh -c "/venv/bin/pip install flake8 && /venv/bin/flake8 ."
- docker-compose run app /venv/bin/python /code/manage.py check
- docker-compose run app /venv/bin/python /code/manage.py makemigrations --check

Wyświetl plik

@ -71,7 +71,7 @@ class People(index.Indexed, ClusterableModel):
# file can't be found.
try:
return self.image.get_rendition('fill-50x50').img_tag()
except:
except: # noqa: E722 FIXME: remove bare 'except:'
return ''
def __str__(self):
@ -154,12 +154,12 @@ class HomePage(Page):
hero_text = models.CharField(
max_length=255,
help_text='Write an introduction for the bakery'
)
)
hero_cta = models.CharField(
verbose_name='Hero CTA',
max_length=255,
help_text='Text to display on Call to Action'
)
)
hero_cta_link = models.ForeignKey(
'wagtailcore.Page',
null=True,
@ -259,8 +259,8 @@ class HomePage(Page):
MultiFieldPanel([
FieldPanel('hero_cta'),
PageChooserPanel('hero_cta_link'),
])
], heading="Hero section"),
]),
], heading="Hero section"),
MultiFieldPanel([
ImageChooserPanel('promo_image'),
FieldPanel('promo_title'),
@ -271,15 +271,15 @@ class HomePage(Page):
MultiFieldPanel([
FieldPanel('featured_section_1_title'),
PageChooserPanel('featured_section_1'),
]),
]),
MultiFieldPanel([
FieldPanel('featured_section_2_title'),
PageChooserPanel('featured_section_2'),
]),
]),
MultiFieldPanel([
FieldPanel('featured_section_3_title'),
PageChooserPanel('featured_section_3'),
])
]),
], heading="Featured homepage sections", classname="collapsible")
]

Wyświetl plik

@ -74,7 +74,7 @@ class BlogPage(Page):
tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
date_published = models.DateField(
"Date article published", blank=True, null=True
)
)
content_panels = Page.content_panels + [
FieldPanel('subtitle', classname="full"),
@ -115,7 +115,7 @@ class BlogPage(Page):
"""
tags = self.tags.all()
for tag in tags:
tag.url = '/'+'/'.join(s.strip('/') for s in [
tag.url = '/' + '/'.join(s.strip('/') for s in [
self.get_parent().url,
'tags',
tag.slug
@ -178,8 +178,8 @@ class BlogIndexPage(RoutablePageMixin, Page):
# related BlogPages for a given Tag or redirect back to the BlogIndexPage.
# More information on RoutablePages is at
# http://docs.wagtail.io/en/latest/reference/contrib/routablepage.html
@route('^tags/$', name='tag_archive')
@route('^tags/([\w-]+)/$', name='tag_archive')
@route(r'^tags/$', name='tag_archive')
@route(r'^tags/([\w-]+)/$', name='tag_archive')
def tag_archive(self, request, tag=None):
try:

Wyświetl plik

@ -6,7 +6,7 @@ from modelcluster.fields import ParentalManyToManyField
from wagtail.admin.edit_handlers import (
FieldPanel, MultiFieldPanel, StreamFieldPanel
)
)
from wagtail.core.fields import StreamField
from wagtail.core.models import Page
from wagtail.search import index

Wyświetl plik

@ -149,7 +149,7 @@ class LocationPage(Page):
Right click Google Maps and select 'What\'s Here'",
validators=[
RegexValidator(
regex='^(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)$',
regex=r'^(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)$',
message='Lat Long must be a comma-separated numeric lat and long',
code='invalid_lat_long'
),

Wyświetl plik

@ -1,4 +1,4 @@
from .base import *
from .base import * # noqa: F403, F401
DEBUG = True

Wyświetl plik

@ -5,7 +5,7 @@ import string
import dj_database_url
import django_cache_url
from .base import *
from .base import * # noqa: F403
DEBUG = os.getenv('DJANGO_DEBUG', 'off') == 'on'

Wyświetl plik

@ -18,7 +18,7 @@ urlpatterns = [
url(r'^search/$', search_views.search, name='search'),
url('^sitemap\.xml$', sitemap),
url(r'^sitemap\.xml$', sitemap),
url(r'^api/v2/', api_router.urls),
]
@ -36,8 +36,8 @@ if settings.DEBUG:
url(
r'^favicon\.ico$', RedirectView.as_view(
url=settings.STATIC_URL + 'img/bread-favicon.ico'
)
)
)
]
# Add views for testing 404 and 500 templates

4
setup.cfg 100644
Wyświetl plik

@ -0,0 +1,4 @@
[flake8]
max-line-length=120
exclude=migrations
ignore=F405,W503