Skip to content

Commit 450e0b4

Browse files
committed
Fix formatting issues reported by flake8
1 parent 59a0be9 commit 450e0b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+525
-189
lines changed

blogs/admin.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ class FeedAggregateAdmin(admin.ModelAdmin):
2222
list_display = ['name', 'slug', 'description']
2323
prepopulated_fields = {'slug': ('name',)}
2424

25+
2526
admin.site.register(Feed)

blogs/templatetags/blogs.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ def feed_list(slug, limit=10):
2323
"""
2424
return BlogEntry.objects.filter(
2525
feed__feedaggregate__slug=slug).order_by('-pub_date')[:limit]
26-

blogs/tests/test_templatetags.py

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def test_feed_list(self):
6363
)
6464
fa.feeds.add(f1, f2)
6565

66-
6766
t = Template("""
6867
{% load blogs %}
6968
{% feed_list 'test' as entries %}

boxes/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
DEFAULT_MARKUP_TYPE = getattr(settings, 'DEFAULT_MARKUP_TYPE', 'restructuredtext')
1717

18+
1819
class Box(ContentManageable):
1920
label = models.SlugField(max_length=100, unique=True)
2021
content = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE)

boxes/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
logging.disable(logging.CRITICAL)
77

8+
89
class BaseTestCase(TestCase):
910
def setUp(self):
1011
self.box = Box.objects.create(label='test', content='test content')
1112

13+
1214
class TemplateTagTests(BaseTestCase):
1315
def render(self, tmpl, **context):
1416
t = template.Template(tmpl)
@@ -22,6 +24,7 @@ def test_tag_invalid_label(self):
2224
r = self.render('{% load boxes %}{% box "missing" %}')
2325
self.assertEqual(r, '')
2426

27+
2528
class ViewTests(BaseTestCase):
2629

2730
@override_settings(ROOT_URLCONF='boxes.urls')

boxes/views.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.shortcuts import get_object_or_404
33
from .models import Box
44

5+
56
def box(request, label):
67
b = get_object_or_404(Box, label=label)
78
return HttpResponse(b.content.rendered)

cms/management/commands/create_initial_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def flush_handler(self, do_flush, verbosity):
6060
'You have provided the --flush argument, this will cleanup '
6161
'the database before creating new data.\n'
6262
'Type \'y\' or \'yes\' to continue, \'n\' or \'no\' to cancel: '
63-
)
63+
)
6464
else:
6565
msg = (
6666
'Note that this command won\'t cleanup the database before '

cms/tests.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,48 @@ def test_get_fieldsets(self):
4848
self.assertEqual(
4949
fieldsets,
5050
[(None, {'fields': ['foo']}),
51-
('CMS metadata', {'fields': [('creator', 'created'), ('last_modified_by', 'updated')], 'classes': ('collapse',)})]
51+
('CMS metadata', {
52+
'fields': [('creator', 'created'), ('last_modified_by', 'updated')],
53+
'classes': ('collapse',)
54+
})]
5255
)
5356

5457
def test_save_model(self):
5558
admin = self.make_admin()
5659
request = mock.Mock()
5760
obj = mock.Mock()
5861
admin.save_model(request=request, obj=obj, form=None, change=False)
59-
self.assertEqual(obj.creator, request.user, "save_model didn't set obj.creator to request.user")
62+
self.assertEqual(
63+
obj.creator,
64+
request.user,
65+
"save_model didn't set obj.creator to request.user"
66+
)
6067

6168
def test_update_model(self):
6269
admin = self.make_admin()
6370
request = mock.Mock()
6471
obj = mock.Mock()
6572
admin.save_model(request=request, obj=obj, form=None, change=True)
66-
self.assertEqual(obj.last_modified_by, request.user, "save_model didn't set obj.last_modified_by to request.user")
73+
self.assertEqual(
74+
obj.last_modified_by,
75+
request.user,
76+
"save_model didn't set obj.last_modified_by to request.user"
77+
)
6778

6879

6980
class TemplateTagsTest(unittest.TestCase):
7081
def test_iso_time_tag(self):
7182
now = datetime.datetime(2014, 1, 1, 12, 0)
7283
template = Template("{% load cms %}{% iso_time_tag now %}")
7384
rendered = template.render(Context({'now': now}))
74-
self.assertIn('<time datetime="2014-01-01T12:00:00"><span class="say-no-more">2014-</span>01-01</time>', rendered)
85+
expected = (
86+
'<time datetime="2014-01-01T12:00:00">'
87+
'<span class="say-no-more">2014-</span>01-01</time>'
88+
)
89+
self.assertIn(
90+
expected,
91+
rendered
92+
)
7593

7694

7795
class Test404(TestCase):

companies/tests.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
class CompaniesTagsTests(TestCase):
88
def test_render_email(self):
99
self.assertEqual(render_email(''), None)
10-
self.assertEqual(render_email('[email protected]'), 'firstname<span>.</span>lastname<span>@</span>domain<span>.</span>com')
10+
self.assertEqual(
11+
render_email('[email protected]'),
12+
'firstname<span>.</span>lastname<span>@</span>domain<span>.</span>com'
13+
)

docs/source/conf.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@
4040
# -- Options for LaTeX output ---------------------------------------------
4141

4242
latex_elements = {
43-
# The paper size ('letterpaper' or 'a4paper').
44-
#'papersize': 'letterpaper',
43+
# The paper size ('letterpaper' or 'a4paper').
44+
# 'papersize': 'letterpaper',
4545

46-
# The font size ('10pt', '11pt' or '12pt').
47-
#'pointsize': '10pt',
46+
# The font size ('10pt', '11pt' or '12pt').
47+
# 'pointsize': '10pt',
4848

49-
# Additional stuff for the LaTeX preamble.
50-
#'preamble': '',
49+
# Additional stuff for the LaTeX preamble.
50+
# 'preamble': '',
5151
}
5252

5353
# Grouping the document tree into LaTeX files. List of tuples
5454
# (source start file, target name, title,
5555
# author, documentclass [howto, manual, or own class]).
5656
latex_documents = [
57-
('index', 'PythonorgWebsite.tex', 'Python.org Website Documentation',
58-
'Python Software Foundation', 'manual'),
57+
('index', 'PythonorgWebsite.tex', 'Python.org Website Documentation',
58+
'Python Software Foundation', 'manual'),
5959
]
6060

6161
# -- Options for manual page output ---------------------------------------
@@ -73,7 +73,7 @@
7373
# (source start file, target name, title, author,
7474
# dir menu entry, description, category)
7575
texinfo_documents = [
76-
('index', 'PythonorgWebsite', 'Python.org Website Documentation',
77-
'Python Software Foundation', 'PythonorgWebsite', '',
78-
'Miscellaneous'),
76+
('index', 'PythonorgWebsite', 'Python.org Website Documentation',
77+
'Python Software Foundation', 'PythonorgWebsite', '',
78+
'Miscellaneous'),
7979
]

downloads/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,6 @@ class Meta:
347347

348348
constraints = [
349349
models.UniqueConstraint(fields=['os', 'release'],
350-
condition=models.Q(download_button=True),
351-
name="only_one_download_per_os_per_release"),
350+
condition=models.Q(download_button=True),
351+
name="only_one_download_per_os_per_release"),
352352
]

downloads/views.py

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def get_redirect_url(self, **kwargs):
4040

4141
class DownloadBase:
4242
""" Include latest releases in all views """
43+
4344
def get_context_data(self, **kwargs):
4445
context = super().get_context_data(**kwargs)
4546
context.update({

events/models.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,10 @@ class RecurringRule(RuleMixin, models.Model):
284284

285285
def __str__(self):
286286
strftime = settings.SHORT_DATETIME_FORMAT
287-
return f'{self.event.title} every {timedelta_nice_repr(self.interval)} since {date(self.dt_start.strftime, strftime)}'
287+
return (
288+
f'{self.event.title} every {timedelta_nice_repr(self.interval)} '
289+
f'since {date(self.dt_start.strftime, strftime)}'
290+
)
288291

289292
def to_rrule(self):
290293
return rrule(

events/tests/test_models.py

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def test_recurring_event(self):
6262
self.assertEqual(self.event.next_time.dt_start, recurring_time_dtstart)
6363
self.assertTrue(rt.valid_dt_end())
6464

65-
6665
rt.begin = now - datetime.timedelta(days=5)
6766
rt.finish = now - datetime.timedelta(days=3)
6867
rt.save()

events/urls.py

+30-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,36 @@
77
urlpatterns = [
88
path('calendars/', views.CalendarList.as_view(), name='calendar_list'),
99
path('submit/', views.EventSubmit.as_view(), name='event_submit'),
10-
path('submit/thanks/', TemplateView.as_view(template_name='events/event_form_thanks.html'), name='event_thanks'),
11-
path('<slug:calendar_slug>/categories/<slug:slug>/', views.EventListByCategory.as_view(), name='eventlist_category'),
12-
path('<slug:calendar_slug>/categories/', views.EventCategoryList.as_view(), name='eventcategory_list'),
13-
path('<slug:calendar_slug>/locations/<int:pk>/', views.EventListByLocation.as_view(), name='eventlist_location'),
14-
path('<slug:calendar_slug>/locations/', views.EventLocationList.as_view(), name='eventlocation_list'),
15-
re_path(r'(?P<calendar_slug>[-a-zA-Z0-9_]+)/date/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', views.EventListByDate.as_view(), name='eventlist_date'),
10+
path(
11+
'submit/thanks/',
12+
TemplateView.as_view(template_name='events/event_form_thanks.html'),
13+
name='event_thanks'
14+
),
15+
path(
16+
'<slug:calendar_slug>/categories/<slug:slug>/',
17+
views.EventListByCategory.as_view(),
18+
name='eventlist_category'
19+
),
20+
path(
21+
'<slug:calendar_slug>/categories/',
22+
views.EventCategoryList.as_view(),
23+
name='eventcategory_list'
24+
),
25+
path(
26+
'<slug:calendar_slug>/locations/<int:pk>/',
27+
views.EventListByLocation.as_view(),
28+
name='eventlist_location'
29+
),
30+
path(
31+
'<slug:calendar_slug>/locations/',
32+
views.EventLocationList.as_view(),
33+
name='eventlocation_list'
34+
),
35+
re_path(
36+
r'(?P<calendar_slug>[-a-zA-Z0-9_]+)/date/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$',
37+
views.EventListByDate.as_view(),
38+
name='eventlist_date'
39+
),
1640
path('<slug:calendar_slug>/<int:pk>/', views.EventDetail.as_view(), name='event_detail'),
1741
path('<slug:calendar_slug>/past/', views.PastEventList.as_view(), name='event_list_past'),
1842
path('<slug:calendar_slug>/', views.EventList.as_view(), name='event_list'),

events/views.py

+24-6
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,17 @@ def get_context_data(self, **kwargs):
6868
class EventList(EventListBase):
6969

7070
def get_queryset(self):
71-
return Event.objects.for_datetime(timezone.now()).filter(calendar__slug=self.kwargs['calendar_slug']).order_by('occurring_rule__dt_start')
71+
return Event.objects.for_datetime(
72+
timezone.now()
73+
).filter(
74+
calendar__slug=self.kwargs['calendar_slug']
75+
).order_by('occurring_rule__dt_start')
7276

7377
def get_context_data(self, **kwargs):
7478
context = super().get_context_data(**kwargs)
75-
context['events_today'] = Event.objects.until_datetime(timezone.now()).filter(calendar__slug=self.kwargs['calendar_slug'])[:2]
79+
context['events_today'] = Event.objects.until_datetime(
80+
timezone.now()
81+
).filter(calendar__slug=self.kwargs['calendar_slug'])[:2]
7682
context['calendar'] = get_object_or_404(Calendar, slug=self.kwargs['calendar_slug'])
7783
return context
7884

@@ -81,7 +87,9 @@ class PastEventList(EventList):
8187
template_name = 'events/event_list_past.html'
8288

8389
def get_queryset(self):
84-
return Event.objects.until_datetime(timezone.now()).filter(calendar__slug=self.kwargs['calendar_slug'])
90+
return Event.objects.until_datetime(
91+
timezone.now()
92+
).filter(calendar__slug=self.kwargs['calendar_slug'])
8593

8694

8795
class EventListByDate(EventList):
@@ -92,12 +100,18 @@ def get_object(self):
92100
return datetime.date(year, month, day)
93101

94102
def get_queryset(self):
95-
return Event.objects.for_datetime(self.get_object()).filter(calendar__slug=self.kwargs['calendar_slug'])
103+
return Event.objects.for_datetime(
104+
self.get_object()
105+
).filter(calendar__slug=self.kwargs['calendar_slug'])
96106

97107

98108
class EventListByCategory(EventList):
99109
def get_object(self, queryset=None):
100-
return get_object_or_404(EventCategory, calendar__slug=self.kwargs['calendar_slug'], slug=self.kwargs['slug'])
110+
return get_object_or_404(
111+
EventCategory,
112+
calendar__slug=self.kwargs['calendar_slug'],
113+
slug=self.kwargs['slug']
114+
)
101115

102116
def get_queryset(self):
103117
qs = super().get_queryset()
@@ -106,7 +120,11 @@ def get_queryset(self):
106120

107121
class EventListByLocation(EventList):
108122
def get_object(self, queryset=None):
109-
return get_object_or_404(EventLocation, calendar__slug=self.kwargs['calendar_slug'], pk=self.kwargs['pk'])
123+
return get_object_or_404(
124+
EventLocation,
125+
calendar__slug=self.kwargs['calendar_slug'],
126+
pk=self.kwargs['pk']
127+
)
110128

111129
def get_queryset(self):
112130
qs = super().get_queryset()

jobs/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def display_description(self):
222222
@property
223223
def display_location(self):
224224
location_parts = [part for part in (self.city, self.region, self.country)
225-
if part]
225+
if part]
226226
location_str = ', '.join(location_parts)
227227
return location_str
228228

jobs/tests/test_views.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -430,15 +430,15 @@ def test_job_telecommute(self):
430430

431431
def test_job_display_name(self):
432432
self.assertEqual(self.job.display_name,
433-
f"{self.job.job_title}, {self.job.company_name}")
433+
f"{self.job.job_title}, {self.job.company_name}")
434434

435435
self.job.company_name = 'ABC'
436436
self.assertEqual(self.job.display_name,
437-
f"{self.job.job_title}, {self.job.company_name}")
437+
f"{self.job.job_title}, {self.job.company_name}")
438438

439439
self.job.company_name = ''
440440
self.assertEqual(self.job.display_name,
441-
f"{self.job.job_title}, {self.job.company_name}")
441+
f"{self.job.job_title}, {self.job.company_name}")
442442

443443
def test_job_display_about(self):
444444
self.job.company_description.raw = 'XYZ'

minutes/urls.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
urlpatterns = [
77
path('', views.MinutesList.as_view(), name='minutes_list'),
88
path('feed/', MinutesFeed(), name='minutes_feed'),
9-
re_path(r'^(?P<year>[0-9]{4})-(?P<month>[0-9]{2})-(?P<day>[0-9]{2})/$', views.MinutesDetail.as_view(), name='minutes_detail'),
9+
re_path(
10+
r'^(?P<year>[0-9]{4})-(?P<month>[0-9]{2})-(?P<day>[0-9]{2})/$',
11+
views.MinutesDetail.as_view(),
12+
name='minutes_detail'
13+
),
1014
]

nominations/forms.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ class Meta:
2323
help_texts = {
2424
"name": "Name of the person you are nominating.",
2525
"email": "Email address for the person you are nominating.",
26-
"previous_board_service": "Has the person previously served on the PSF Board? If so what year(s)? Otherwise 'New board member'.",
26+
"previous_board_service": (
27+
"Has the person previously served on the PSF Board? "
28+
"If so what year(s)? Otherwise 'New board member'."
29+
),
2730
"employer": "Nominee's current employer.",
2831
"other_affiliations": "Any other relevant affiliations the Nominee has.",
2932
"nomination_statement": "Markdown syntax supported.",
@@ -37,7 +40,10 @@ def __init__(self, *args, **kwargs):
3740

3841
self_nomination = forms.BooleanField(
3942
required=False,
40-
help_text="If you are nominating yourself, we will automatically associate the nomination with your python.org user.",
43+
help_text=(
44+
"If you are nominating yourself, we will automatically "
45+
"associate the nomination with your python.org user."
46+
),
4147
)
4248

4349
def clean_self_nomination(self):
@@ -46,7 +52,8 @@ def clean_self_nomination(self):
4652
if not self.request.user.first_name or not self.request.user.last_name:
4753
raise forms.ValidationError(
4854
mark_safe(
49-
'You must set your First and Last name in your <a href="/users/edit/">User Profile</a> to self nominate.'
55+
'You must set your First and Last name in your '
56+
'<a href="/users/edit/">User Profile</a> to self nominate.'
5057
)
5158
)
5259

@@ -60,5 +67,8 @@ class Meta:
6067
"accepted",
6168
)
6269
help_texts = {
63-
"accepted": "If selected, this nomination will be considered accepted and displayed once nominations are public.",
70+
"accepted": (
71+
"If selected, this nomination will be considered "
72+
"accepted and displayed once nominations are public."
73+
),
6474
}

0 commit comments

Comments
 (0)