Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix issue #2135 - project code style and linter tools #2196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix formatting issues reported by flake8
  • Loading branch information
luzfcb committed Dec 13, 2022
commit 450e0b41b7582509b0fe4c3568362cf7b1621e7d
1 change: 1 addition & 0 deletions 1 blogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ class FeedAggregateAdmin(admin.ModelAdmin):
list_display = ['name', 'slug', 'description']
prepopulated_fields = {'slug': ('name',)}


admin.site.register(Feed)
1 change: 0 additions & 1 deletion 1 blogs/templatetags/blogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ def feed_list(slug, limit=10):
"""
return BlogEntry.objects.filter(
feed__feedaggregate__slug=slug).order_by('-pub_date')[:limit]

1 change: 0 additions & 1 deletion 1 blogs/tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def test_feed_list(self):
)
fa.feeds.add(f1, f2)


t = Template("""
{% load blogs %}
{% feed_list 'test' as entries %}
Expand Down
1 change: 1 addition & 0 deletions 1 boxes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

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


class Box(ContentManageable):
label = models.SlugField(max_length=100, unique=True)
content = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE)
Expand Down
3 changes: 3 additions & 0 deletions 3 boxes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

logging.disable(logging.CRITICAL)


class BaseTestCase(TestCase):
def setUp(self):
self.box = Box.objects.create(label='test', content='test content')


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


class ViewTests(BaseTestCase):

@override_settings(ROOT_URLCONF='boxes.urls')
Expand Down
1 change: 1 addition & 0 deletions 1 boxes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.shortcuts import get_object_or_404
from .models import Box


def box(request, label):
b = get_object_or_404(Box, label=label)
return HttpResponse(b.content.rendered)
2 changes: 1 addition & 1 deletion 2 cms/management/commands/create_initial_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def flush_handler(self, do_flush, verbosity):
'You have provided the --flush argument, this will cleanup '
'the database before creating new data.\n'
'Type \'y\' or \'yes\' to continue, \'n\' or \'no\' to cancel: '
)
)
else:
msg = (
'Note that this command won\'t cleanup the database before '
Expand Down
26 changes: 22 additions & 4 deletions 26 cms/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,48 @@ def test_get_fieldsets(self):
self.assertEqual(
fieldsets,
[(None, {'fields': ['foo']}),
('CMS metadata', {'fields': [('creator', 'created'), ('last_modified_by', 'updated')], 'classes': ('collapse',)})]
('CMS metadata', {
'fields': [('creator', 'created'), ('last_modified_by', 'updated')],
'classes': ('collapse',)
})]
)

def test_save_model(self):
admin = self.make_admin()
request = mock.Mock()
obj = mock.Mock()
admin.save_model(request=request, obj=obj, form=None, change=False)
self.assertEqual(obj.creator, request.user, "save_model didn't set obj.creator to request.user")
self.assertEqual(
obj.creator,
request.user,
"save_model didn't set obj.creator to request.user"
)

def test_update_model(self):
admin = self.make_admin()
request = mock.Mock()
obj = mock.Mock()
admin.save_model(request=request, obj=obj, form=None, change=True)
self.assertEqual(obj.last_modified_by, request.user, "save_model didn't set obj.last_modified_by to request.user")
self.assertEqual(
obj.last_modified_by,
request.user,
"save_model didn't set obj.last_modified_by to request.user"
)


class TemplateTagsTest(unittest.TestCase):
def test_iso_time_tag(self):
now = datetime.datetime(2014, 1, 1, 12, 0)
template = Template("{% load cms %}{% iso_time_tag now %}")
rendered = template.render(Context({'now': now}))
self.assertIn('<time datetime="2014-01-01T12:00:00"><span class="say-no-more">2014-</span>01-01</time>', rendered)
expected = (
'<time datetime="2014-01-01T12:00:00">'
'<span class="say-no-more">2014-</span>01-01</time>'
)
self.assertIn(
expected,
rendered
)


class Test404(TestCase):
Expand Down
5 changes: 4 additions & 1 deletion 5 companies/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
class CompaniesTagsTests(TestCase):
def test_render_email(self):
self.assertEqual(render_email(''), None)
self.assertEqual(render_email('firstname.lastname@domain.com'), 'firstname<span>.</span>lastname<span>@</span>domain<span>.</span>com')
self.assertEqual(
render_email('firstname.lastname@domain.com'),
'firstname<span>.</span>lastname<span>@</span>domain<span>.</span>com'
)
22 changes: 11 additions & 11 deletions 22 docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@
# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}

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

# -- Options for manual page output ---------------------------------------
Expand All @@ -73,7 +73,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'PythonorgWebsite', 'Python.org Website Documentation',
'Python Software Foundation', 'PythonorgWebsite', '',
'Miscellaneous'),
('index', 'PythonorgWebsite', 'Python.org Website Documentation',
'Python Software Foundation', 'PythonorgWebsite', '',
'Miscellaneous'),
]
4 changes: 2 additions & 2 deletions 4 downloads/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,6 @@ class Meta:

constraints = [
models.UniqueConstraint(fields=['os', 'release'],
condition=models.Q(download_button=True),
name="only_one_download_per_os_per_release"),
condition=models.Q(download_button=True),
name="only_one_download_per_os_per_release"),
]
1 change: 1 addition & 0 deletions 1 downloads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_redirect_url(self, **kwargs):

class DownloadBase:
""" Include latest releases in all views """

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
Expand Down
5 changes: 4 additions & 1 deletion 5 events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ class RecurringRule(RuleMixin, models.Model):

def __str__(self):
strftime = settings.SHORT_DATETIME_FORMAT
return f'{self.event.title} every {timedelta_nice_repr(self.interval)} since {date(self.dt_start.strftime, strftime)}'
return (
f'{self.event.title} every {timedelta_nice_repr(self.interval)} '
f'since {date(self.dt_start.strftime, strftime)}'
)

def to_rrule(self):
return rrule(
Expand Down
1 change: 0 additions & 1 deletion 1 events/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def test_recurring_event(self):
self.assertEqual(self.event.next_time.dt_start, recurring_time_dtstart)
self.assertTrue(rt.valid_dt_end())


rt.begin = now - datetime.timedelta(days=5)
rt.finish = now - datetime.timedelta(days=3)
rt.save()
Expand Down
36 changes: 30 additions & 6 deletions 36 events/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,36 @@
urlpatterns = [
path('calendars/', views.CalendarList.as_view(), name='calendar_list'),
path('submit/', views.EventSubmit.as_view(), name='event_submit'),
path('submit/thanks/', TemplateView.as_view(template_name='events/event_form_thanks.html'), name='event_thanks'),
path('<slug:calendar_slug>/categories/<slug:slug>/', views.EventListByCategory.as_view(), name='eventlist_category'),
path('<slug:calendar_slug>/categories/', views.EventCategoryList.as_view(), name='eventcategory_list'),
path('<slug:calendar_slug>/locations/<int:pk>/', views.EventListByLocation.as_view(), name='eventlist_location'),
path('<slug:calendar_slug>/locations/', views.EventLocationList.as_view(), name='eventlocation_list'),
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'),
path(
'submit/thanks/',
TemplateView.as_view(template_name='events/event_form_thanks.html'),
name='event_thanks'
),
path(
'<slug:calendar_slug>/categories/<slug:slug>/',
views.EventListByCategory.as_view(),
name='eventlist_category'
),
path(
'<slug:calendar_slug>/categories/',
views.EventCategoryList.as_view(),
name='eventcategory_list'
),
path(
'<slug:calendar_slug>/locations/<int:pk>/',
views.EventListByLocation.as_view(),
name='eventlist_location'
),
path(
'<slug:calendar_slug>/locations/',
views.EventLocationList.as_view(),
name='eventlocation_list'
),
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'
),
path('<slug:calendar_slug>/<int:pk>/', views.EventDetail.as_view(), name='event_detail'),
path('<slug:calendar_slug>/past/', views.PastEventList.as_view(), name='event_list_past'),
path('<slug:calendar_slug>/', views.EventList.as_view(), name='event_list'),
Expand Down
30 changes: 24 additions & 6 deletions 30 events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,17 @@ def get_context_data(self, **kwargs):
class EventList(EventListBase):

def get_queryset(self):
return Event.objects.for_datetime(timezone.now()).filter(calendar__slug=self.kwargs['calendar_slug']).order_by('occurring_rule__dt_start')
return Event.objects.for_datetime(
timezone.now()
).filter(
calendar__slug=self.kwargs['calendar_slug']
).order_by('occurring_rule__dt_start')

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['events_today'] = Event.objects.until_datetime(timezone.now()).filter(calendar__slug=self.kwargs['calendar_slug'])[:2]
context['events_today'] = Event.objects.until_datetime(
timezone.now()
).filter(calendar__slug=self.kwargs['calendar_slug'])[:2]
context['calendar'] = get_object_or_404(Calendar, slug=self.kwargs['calendar_slug'])
return context

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

def get_queryset(self):
return Event.objects.until_datetime(timezone.now()).filter(calendar__slug=self.kwargs['calendar_slug'])
return Event.objects.until_datetime(
timezone.now()
).filter(calendar__slug=self.kwargs['calendar_slug'])


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

def get_queryset(self):
return Event.objects.for_datetime(self.get_object()).filter(calendar__slug=self.kwargs['calendar_slug'])
return Event.objects.for_datetime(
self.get_object()
).filter(calendar__slug=self.kwargs['calendar_slug'])


class EventListByCategory(EventList):
def get_object(self, queryset=None):
return get_object_or_404(EventCategory, calendar__slug=self.kwargs['calendar_slug'], slug=self.kwargs['slug'])
return get_object_or_404(
EventCategory,
calendar__slug=self.kwargs['calendar_slug'],
slug=self.kwargs['slug']
)

def get_queryset(self):
qs = super().get_queryset()
Expand All @@ -106,7 +120,11 @@ def get_queryset(self):

class EventListByLocation(EventList):
def get_object(self, queryset=None):
return get_object_or_404(EventLocation, calendar__slug=self.kwargs['calendar_slug'], pk=self.kwargs['pk'])
return get_object_or_404(
EventLocation,
calendar__slug=self.kwargs['calendar_slug'],
pk=self.kwargs['pk']
)

def get_queryset(self):
qs = super().get_queryset()
Expand Down
2 changes: 1 addition & 1 deletion 2 jobs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def display_description(self):
@property
def display_location(self):
location_parts = [part for part in (self.city, self.region, self.country)
if part]
if part]
location_str = ', '.join(location_parts)
return location_str

Expand Down
6 changes: 3 additions & 3 deletions 6 jobs/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,15 @@ def test_job_telecommute(self):

def test_job_display_name(self):
self.assertEqual(self.job.display_name,
f"{self.job.job_title}, {self.job.company_name}")
f"{self.job.job_title}, {self.job.company_name}")

self.job.company_name = 'ABC'
self.assertEqual(self.job.display_name,
f"{self.job.job_title}, {self.job.company_name}")
f"{self.job.job_title}, {self.job.company_name}")

self.job.company_name = ''
self.assertEqual(self.job.display_name,
f"{self.job.job_title}, {self.job.company_name}")
f"{self.job.job_title}, {self.job.company_name}")

def test_job_display_about(self):
self.job.company_description.raw = 'XYZ'
Expand Down
6 changes: 5 additions & 1 deletion 6 minutes/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
urlpatterns = [
path('', views.MinutesList.as_view(), name='minutes_list'),
path('feed/', MinutesFeed(), name='minutes_feed'),
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'),
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'
),
]
18 changes: 14 additions & 4 deletions 18 nominations/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class Meta:
help_texts = {
"name": "Name of the person you are nominating.",
"email": "Email address for the person you are nominating.",
"previous_board_service": "Has the person previously served on the PSF Board? If so what year(s)? Otherwise 'New board member'.",
"previous_board_service": (
"Has the person previously served on the PSF Board? "
"If so what year(s)? Otherwise 'New board member'."
),
"employer": "Nominee's current employer.",
"other_affiliations": "Any other relevant affiliations the Nominee has.",
"nomination_statement": "Markdown syntax supported.",
Expand All @@ -37,7 +40,10 @@ def __init__(self, *args, **kwargs):

self_nomination = forms.BooleanField(
required=False,
help_text="If you are nominating yourself, we will automatically associate the nomination with your python.org user.",
help_text=(
"If you are nominating yourself, we will automatically "
"associate the nomination with your python.org user."
),
)

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

Expand All @@ -60,5 +67,8 @@ class Meta:
"accepted",
)
help_texts = {
"accepted": "If selected, this nomination will be considered accepted and displayed once nominations are public.",
"accepted": (
"If selected, this nomination will be considered "
"accepted and displayed once nominations are public."
),
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.