Skip to content

Commit

Permalink
Upgrade Python syntax with pyupgrade --py37-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored and jezdez committed Jan 8, 2022
1 parent c3573af commit d2b3e92
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 36 deletions.
17 changes: 8 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# django-newsletter documentation build configuration file, created by
# sphinx-quickstart on Wed Nov 13 13:53:07 2013.
Expand Down Expand Up @@ -76,8 +75,8 @@
master_doc = 'index'

# General information about the project.
project = u'django-newsletter'
copyright = u'2013, Mathijs de Bruin'
project = 'django-newsletter'
copyright = '2013, Mathijs de Bruin'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -224,8 +223,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'django-newsletter.tex', u'django-newsletter Documentation',
u'Mathijs de Bruin', 'manual'),
('index', 'django-newsletter.tex', 'django-newsletter Documentation',
'Mathijs de Bruin', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -254,8 +253,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'django-newsletter', u'django-newsletter Documentation',
[u'Mathijs de Bruin'], 1)
('index', 'django-newsletter', 'django-newsletter Documentation',
['Mathijs de Bruin'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -268,8 +267,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'django-newsletter', u'django-newsletter Documentation',
u'Mathijs de Bruin', 'django-newsletter', 'One line description of project.',
('index', 'django-newsletter', 'django-newsletter Documentation',
'Mathijs de Bruin', 'django-newsletter', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
2 changes: 1 addition & 1 deletion newsletter/addressimport/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from newsletter.models import Subscription


class AddressList(object):
class AddressList:
""" List with unique addresses. """

def __init__(self, newsletter, ignore_errors=False):
Expand Down
2 changes: 1 addition & 1 deletion newsletter/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class NewsletterAdminLinkMixin:
def admin_newsletter(self, obj):
opts = Newsletter._meta
newsletter = obj.newsletter
url = reverse('admin:%s_%s_change' % (opts.app_label, opts.model_name),
url = reverse(f'admin:{opts.app_label}_{opts.model_name}_change',
args=(newsletter.id,), current_app=self.admin_site.name)

return format_html('<a href="{}">{}</a>', url, newsletter)
Expand Down
1 change: 0 additions & 1 deletion newsletter/management/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
# management commands for the newsletter
1 change: 0 additions & 1 deletion newsletter/management/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
# management commands for the newsletter
1 change: 0 additions & 1 deletion newsletter/management/commands/submit_newsletter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
actual sending of the submissions
"""
Expand Down
7 changes: 2 additions & 5 deletions newsletter/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import sorl.thumbnail.fields
import newsletter.utils
Expand Down Expand Up @@ -108,7 +105,7 @@ class Migration(migrations.Migration):
),
migrations.AlterUniqueTogether(
name='subscription',
unique_together=set([('user', 'email_field', 'newsletter')]),
unique_together={('user', 'email_field', 'newsletter')},
),
migrations.AddField(
model_name='submission',
Expand All @@ -124,7 +121,7 @@ class Migration(migrations.Migration):
),
migrations.AlterUniqueTogether(
name='message',
unique_together=set([('slug', 'newsletter')]),
unique_together={('slug', 'newsletter')},
),
migrations.AddField(
model_name='article',
Expand Down
3 changes: 0 additions & 3 deletions newsletter/migrations/0002_auto_20150416_1555.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import django.db.models.manager
import django.contrib.sites.managers
Expand Down
4 changes: 1 addition & 3 deletions newsletter/migrations/0003_auto_20160226_1518.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import logging
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -34,6 +32,6 @@ class Migration(migrations.Migration):
migrations.RunPython(renumerate_article_sortorder),
migrations.AlterUniqueTogether(
name='article',
unique_together=set([('post', 'sortorder')]),
unique_together={('post', 'sortorder')},
),
]
3 changes: 0 additions & 3 deletions newsletter/migrations/0004_auto_20180407_1043.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import newsletter.models

Expand Down
4 changes: 2 additions & 2 deletions newsletter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def __str__(self):
@cached_property
def extra_headers(self):
return {
'List-Unsubscribe': 'http://%s%s' % (
'List-Unsubscribe': 'http://{}{}'.format(
Site.objects.get_current().domain,
reverse('newsletter_unsubscribe_request',
args=[self.message.newsletter.slug])
Expand Down Expand Up @@ -743,6 +743,6 @@ def get_address(name, email):
if LooseVersion(django.get_version()) < LooseVersion('1.9'):
name = name.encode('ascii', 'ignore').decode('ascii').strip()
if name:
return '%s <%s>' % (name, email)
return f'{name} <{email}>'
else:
return '%s' % email
2 changes: 1 addition & 1 deletion newsletter/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __getattr__(self, attr):
try:
setting = getattr(
django_settings,
'%s_%s' % (self.settings_prefix, attr),
f'{self.settings_prefix}_{attr}',
)
except AttributeError:
if not attr.startswith('DEFAULT_'):
Expand Down
2 changes: 1 addition & 1 deletion newsletter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def form_valid(self, form):
try:
self.subscription.send_activation_email(action=self.action)

except (SMTPException, socket.error) as e:
except (SMTPException, OSError) as e:
logger.exception(
'Error %s while submitting email to %s.',
e, self.subscription.email
Expand Down
8 changes: 4 additions & 4 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_listform(self):
for form in formset.forms:
self.assertTrue(
form.instance.newsletter in self.newsletters,
"%s not in %s" % (form.instance.newsletter, self.newsletters)
f"{form.instance.newsletter} not in {self.newsletters}"
)
self.assertContains(response, form['id'])
self.assertContains(response, form['subscribed'])
Expand Down Expand Up @@ -560,7 +560,7 @@ def test_subscribe_request_post(self):
self.assertEqual(len(mail.outbox), 1)

activate_url = subscription.subscribe_activate_url()
full_activate_url = 'http://%s%s' % (self.site.domain, activate_url)
full_activate_url = f'http://{self.site.domain}{activate_url}'

self.assertEmailContains(full_activate_url)

Expand Down Expand Up @@ -895,7 +895,7 @@ def test_unsubscribe_request_post(self):
self.assertEqual(len(mail.outbox), 1)

activate_url = subscription.unsubscribe_activate_url()
full_activate_url = 'http://%s%s' % (self.site.domain, activate_url)
full_activate_url = f'http://{self.site.domain}{activate_url}'

self.assertEmailContains(full_activate_url)

Expand Down Expand Up @@ -1034,7 +1034,7 @@ def test_update_request_post(self):
self.assertEqual(len(mail.outbox), 1)

activate_url = subscription.update_activate_url()
full_activate_url = 'http://%s%s' % (self.site.domain, activate_url)
full_activate_url = f'http://{self.site.domain}{activate_url}'

self.assertEmailContains(full_activate_url)

Expand Down

0 comments on commit d2b3e92

Please sign in to comment.