Skip to content
This repository has been archived by the owner on Dec 9, 2021. It is now read-only.

Commit

Permalink
135: tighten up flake8 to also enforce 88-char lines, matching black
Browse files Browse the repository at this point in the history
This commit contains some (manual) changes to over-long lines caught by flake8 that black _didn't_ auto-fix, because they were long strings (see psf/black#182)
  • Loading branch information
Steve Jalim committed Sep 17, 2019
1 parent b545737 commit 6799e72
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 67 deletions.
30 changes: 19 additions & 11 deletions developerportal/apps/articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ class Articles(Page):
FieldPanel("keywords"),
],
heading="SEO",
help_text="Optional fields to override the default title and description for SEO purposes",
help_text=(
"Optional fields to override the default title "
"and description for SEO purposes"
),
)
]

Expand Down Expand Up @@ -147,7 +150,8 @@ class Article(Page):
)
body = CustomStreamField(
help_text=(
"The main article content. Supports rich text, images, embed via URL, embed via HTML, and inline code snippets"
"The main article content. Supports rich text, images, embed via URL, "
"embed via HTML, and inline code snippets"
)
)
related_links_mdn = StreamField(
Expand Down Expand Up @@ -187,8 +191,8 @@ class Article(Page):
blank=True,
null=True,
help_text=(
"Optional list of the article’s authors. Use ‘External author’ to add guest authors without creating a "
"profile on the system"
"Optional list of the article’s authors. Use ‘External author’ to add "
"guest authors without creating a profile on the system"
),
)
keywords = ClusterTaggableManager(through=ArticleTag, blank=True)
Expand All @@ -200,8 +204,8 @@ class Article(Page):
[ImageChooserPanel("image")],
heading="Image",
help_text=(
"Optional header image. If not specified a fallback will be used. This image is also shown when sharing "
"this page via social media"
"Optional header image. If not specified a fallback will be used. "
"This image is also shown when sharing this page via social media"
),
),
StreamFieldPanel("body"),
Expand All @@ -223,8 +227,9 @@ class Article(Page):
[InlinePanel("topics")],
heading="Topics",
help_text=(
"The topic pages this article will appear on. The first topic in the list will be treated as the "
"primary topic and will be shown in the page’s related content."
"The topic pages this article will appear on. The first topic in the "
"list will be treated as the primary topic and will be shown in the "
"page’s related content."
),
),
MultiFieldPanel(
Expand All @@ -234,7 +239,10 @@ class Article(Page):
FieldPanel("keywords"),
],
heading="SEO",
help_text="Optional fields to override the default title and description for SEO purposes",
help_text=(
"Optional fields to override the default title and description "
"for SEO purposes"
),
),
]

Expand Down Expand Up @@ -267,8 +275,8 @@ def read_time(self):

@property
def related_resources(self):
"""Returns resources that are related to the current resource, i.e. live, public articles and videos which
have the same topics."""
"""Returns resources that are related to the current resource, i.e.
live, public articles and videos which have the same topics."""
topic_pks = [topic.topic.pk for topic in self.topics.all()]
return get_combined_articles_and_videos(self, topics__topic__pk__in=topic_pks)

Expand Down
8 changes: 6 additions & 2 deletions developerportal/apps/common/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class AgendaItemBlock(blocks.StructBlock):


class ExternalLinkBlock(blocks.StructBlock):
"""Content for a link to an external page without an image, e.g. MDN related links."""
"""Content for a link to an external page without an image,
e.g. MDN related links."""

title = blocks.CharBlock(label="Name")
url = blocks.URLBlock()
Expand Down Expand Up @@ -102,4 +103,7 @@ class PersonalWebsiteBlock(blocks.StructBlock):
icon = ImageChooserBlock(required=False)

class Meta:
help_text = "Details of any other personal website, to be displayed alongside social profiles."
help_text = (
"Details of any other personal website, to be displayed alongside "
"social profiles."
)
3 changes: 2 additions & 1 deletion developerportal/apps/common/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def __init__(self, *args, **kwargs):
"embed_html",
RawHTMLBlock(
help_text=(
"Warning: be careful what you paste here, since this field could introduce XSS (or similar) bugs. "
"Warning: be careful what you paste here, since this "
"field could introduce XSS (or similar) bugs. "
"This field is meant solely for third-party embeds."
)
),
Expand Down
9 changes: 6 additions & 3 deletions developerportal/apps/common/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def expand_db_attributes(cls, attrs):
# Let's add the target attr, and also rel="noopener" + noreferrer fallback.
# See https://github.com/whatwg/html/issues/4078.
return (
'<a href="%s" class="external-link" target="_blank" rel="noopener noreferrer">'
% escape(href)
'<a href="%s" class="external-link" target="_blank" '
'rel="noopener noreferrer">' % escape(href)
)


Expand All @@ -33,7 +33,10 @@ def _custom_slug_help_text():
# back to example.com instead of the Wagtail default.
default_site = Site.objects.filter(is_default_site=True).first()
base_url = default_site.root_url if default_site else "https://example.com"
return f"The name of the page as it will appear in URLs e.g. for an article: {base_url}/articles/slug/"
return (
f"The name of the page as it will appear in URLs e.g. "
f"for an article: {base_url}/articles/slug/"
)


try:
Expand Down
8 changes: 6 additions & 2 deletions developerportal/apps/content/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class ContentPage(Page):
)
body = CustomStreamField(
help_text=(
"Main page body content. Supports rich text, images, embed via URL, embed via HTML, and inline code snippets"
"Main page body content. Supports rich text, images, embed via URL, "
"embed via HTML, and inline code snippets"
)
)

Expand Down Expand Up @@ -82,7 +83,10 @@ class ContentPage(Page):
FieldPanel("keywords"),
],
heading="SEO",
help_text="Optional fields to override the default title and description for SEO purposes",
help_text=(
"Optional fields to override the default title and "
"description for SEO purposes"
),
)
]

Expand Down
38 changes: 26 additions & 12 deletions developerportal/apps/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ class Events(Page):
FieldPanel("keywords"),
],
heading="SEO",
help_text="Optional fields to override the default title and description for SEO purposes",
help_text=(
"Optional fields to override the default title and description "
"for SEO purposes"
),
)
]

Expand Down Expand Up @@ -169,7 +172,8 @@ class Event(Page):
blank=True,
null=True,
help_text=(
"Optional body content. Supports rich text, images, embed via URL, embed via HTML, and inline code snippets"
"Optional body content. Supports rich text, images, embed via URL, "
"embed via HTML, and inline code snippets"
),
)
agenda = StreamField(
Expand Down Expand Up @@ -227,8 +231,8 @@ class Event(Page):
[ImageChooserPanel("image")],
heading="Image",
help_text=(
"Optional header image. If not specified a fallback will be used. This image is also shown when sharing "
"this page via social media"
"Optional header image. If not specified a fallback will be used. "
"This image is also shown when sharing this page via social media"
),
),
StreamFieldPanel("body"),
Expand Down Expand Up @@ -256,9 +260,11 @@ class Event(Page):
heading="Event details",
classname="collapsible",
help_text=mark_safe(
"Optional time and location information for this event. Latitude and longitude are used to show a map "
"of the event’s location. For more information on finding these values for a given location, "
'<a href="https://support.google.com/maps/answer/18539">see this article</a>'
"Optional time and location information for this event. Latitude and "
"longitude are used to show a map of the event’s location. For more "
"information on finding these values for a given location, "
"'<a href='https://support.google.com/maps/answer/18539'>"
"see this article</a>"
),
),
MultiFieldPanel(
Expand All @@ -275,14 +281,18 @@ class Event(Page):
],
heading="Event address",
classname="collapsible",
help_text="Optional address fields. The city and country are also shown on event cards",
help_text=(
"Optional address fields. The city and country are also shown "
"on event cards"
),
),
MultiFieldPanel(
[InlinePanel("topics")],
heading="Topics",
help_text=(
"These are the topic pages the event will appear on. The first topic in the list will be treated as the "
"primary topic and will be shown in the page’s related content."
"These are the topic pages the event will appear on. The first topic "
"in the list will be treated as the primary topic and will be shown "
"in the page’s related content."
),
),
MultiFieldPanel(
Expand All @@ -292,7 +302,10 @@ class Event(Page):
FieldPanel("keywords"),
],
heading="SEO",
help_text="Optional fields to override the default title and description for SEO purposes",
help_text=(
"Optional fields to override the default title and description "
"for SEO purposes"
),
),
]

Expand Down Expand Up @@ -338,7 +351,8 @@ def event_dates(self):

@property
def event_dates_full(self):
"""Return a formatted string of the event start and end dates, including the year"""
"""Return a formatted string of the event start and end dates,
including the year"""
return self.event_dates + self.start_date.strftime(", %Y")

def has_speaker(self, person):
Expand Down
25 changes: 16 additions & 9 deletions developerportal/apps/externalcontent/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class ExternalContent(Page):
"URL",
blank=True,
default="",
help_text="The URL that this content links to, max. 2048 characters for compatibility with older web browsers",
help_text=(
"The URL that this content links to, max. 2048 characters "
"for compatibility with older web browsers"
),
max_length=2048,
)
image = ForeignKey(
Expand All @@ -63,8 +66,8 @@ class ExternalContent(Page):
[ImageChooserPanel("image")],
heading="Image",
help_text=(
"Optional header image. If not specified a fallback will be used. This image is also shown when sharing "
"this page via social media"
"Optional header image. If not specified a fallback will be used. "
"This image is also shown when sharing this page via social media"
),
),
FieldPanel("external_url"),
Expand Down Expand Up @@ -122,8 +125,8 @@ class ExternalArticle(ExternalContent):
blank=True,
null=True,
help_text=(
"Optional list of the article’s authors. Use ‘External author’ to add guest authors without creating a "
"profile on the system"
"Optional list of the article’s authors. Use ‘External author’ to add "
"guest authors without creating a profile on the system"
),
)
read_time = CharField(
Expand Down Expand Up @@ -226,14 +229,16 @@ class ExternalEvent(ExternalContent):
"topics",
heading="Topics",
help_text=(
"Optional topics this event is associated with. Adds the event to the list of events on those topic pages"
"Optional topics this event is associated with. "
"Adds the event to the list of events on those topic pages"
),
),
InlinePanel(
"speakers",
heading="Speakers",
help_text=(
"Optional speakers associated with this event. Adds the event to the list of events on their profile pages"
"Optional speakers associated with this event. "
"Adds the event to the list of events on their profile pages"
),
),
]
Expand Down Expand Up @@ -269,7 +274,8 @@ def event_dates(self):

@property
def event_dates_full(self):
"""Return a formatted string of the event start and end dates, including the year"""
"""Return a formatted string of the event start and end dates,
including the year"""
return self.event_dates + self.start_date.strftime(", %Y")


Expand Down Expand Up @@ -315,7 +321,8 @@ class ExternalVideo(ExternalContent):
blank=True,
null=True,
help_text=(
"Optional video duration in MM:SS format e.g. “12:34”. Shown when the video is displayed as a card"
"Optional video duration in MM:SS format e.g. “12:34”. "
"Shown when the video is displayed as a card"
),
)

Expand Down
19 changes: 15 additions & 4 deletions developerportal/apps/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class HomePage(Page):
),
null=True,
blank=True,
help_text="Optional promo space under the header for linking to external sites, max. 2",
help_text=(
"Optional promo space under the header "
"for linking to external sites, max. 2"
),
)
featured = StreamField(
StreamBlock(
Expand Down Expand Up @@ -116,7 +119,9 @@ class HomePage(Page):
MultiFieldPanel(
[ImageChooserPanel("image")],
heading="Image",
help_text="Optional image shown when sharing this page through social media",
help_text=(
"Optional image shown when sharing this page through social media"
),
),
StreamFieldPanel("external_promos"),
StreamFieldPanel("featured"),
Expand All @@ -142,7 +147,10 @@ class HomePage(Page):
],
heading="Card overrides",
help_text=(
"Optional fields to override the default title, description and image when this page is shown as a card"
(
"Optional fields to override the default title, "
"description and image when this page is shown as a card"
)
),
)
]
Expand All @@ -156,7 +164,10 @@ class HomePage(Page):
FieldPanel("keywords"),
],
heading="SEO",
help_text="Optional fields to override the default title and description for SEO purposes",
help_text=(
"Optional fields to override the default "
"title and description for SEO purposes"
),
)
]

Expand Down
14 changes: 10 additions & 4 deletions developerportal/apps/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ class People(Page):
FieldPanel("keywords"),
],
heading="SEO",
help_text="Optional fields to override the default title and description for SEO purposes",
help_text=(
"Optional fields to override the default title and description "
"for SEO purposes"
),
)
]

Expand Down Expand Up @@ -179,8 +182,8 @@ class Person(Page):
[ImageChooserPanel("image")],
heading="Image",
help_text=(
"Optional header image. If not specified a fallback will be used. This image is also shown when sharing "
"this page via social media"
"Optional header image. If not specified a fallback will be used. "
"This image is also shown when sharing this page via social media"
),
),
]
Expand Down Expand Up @@ -214,7 +217,10 @@ class Person(Page):
FieldPanel("keywords"),
],
heading="SEO",
help_text="Optional fields to override the default title and description for SEO purposes",
help_text=(
"Optional fields to override the default title and description "
"for SEO purposes"
),
),
]

Expand Down
Loading

0 comments on commit 6799e72

Please sign in to comment.