Commit 4c5c5d00eba6fd4f02cf0ebae90c81f5fd19377d

Authored by Claude Paroz
1 parent 18ecbd6e

Removed support for Python 2

... ... @@ -2,8 +2,6 @@ dist: xenial
2 2 language: python
3 3 matrix:
4 4 include:
5   - - python: 2.7
6   - env: TOXENV=py27-django111
7 5 - python: 3.4
8 6 env: TOXENV=py34-django111
9 7 - python: 3.4
... ...
... ... @@ -3,6 +3,11 @@
3 3 History
4 4 =======
5 5
  6 +X.Y.Z (YYYY-MM-DD)
  7 +------------------
  8 +
  9 +* Removed support for Python 2.
  10 +
6 11 1.9.2 (2019-12-03)
7 12 ------------------
8 13
... ...
1   -from __future__ import unicode_literals
2   -
3 1 from django.conf import settings
4 2 from django.contrib.contenttypes.fields import GenericForeignKey
5 3 from django.contrib.contenttypes.models import ContentType
... ... @@ -8,7 +6,6 @@ from django.db import models
8 6 from django.urls import reverse
9 7 from django.utils import timezone
10 8 from django.utils.translation import gettext_lazy as _
11   -from six import python_2_unicode_compatible
12 9
13 10 from .managers import CommentManager
14 11
... ... @@ -45,7 +42,6 @@ class BaseCommentAbstractModel(models.Model):
45 42 )
46 43
47 44
48   -@python_2_unicode_compatible
49 45 class CommentAbstractModel(BaseCommentAbstractModel):
50 46 """
51 47 A user comment about some object.
... ... @@ -90,7 +86,7 @@ class CommentAbstractModel(BaseCommentAbstractModel):
90 86 def save(self, *args, **kwargs):
91 87 if self.submit_date is None:
92 88 self.submit_date = timezone.now()
93   - super(CommentAbstractModel, self).save(*args, **kwargs)
  89 + super().save(*args, **kwargs)
94 90
95 91 def _get_userinfo(self):
96 92 """
... ...
1   -from __future__ import unicode_literals
2   -
3 1 from django.contrib import admin
4 2 from django.contrib.auth import get_user_model
5 3 from django.utils.translation import gettext_lazy as _, ngettext
... ... @@ -8,7 +6,7 @@ from django_comments import get_model
8 6 from django_comments.views.moderation import perform_flag, perform_approve, perform_delete
9 7
10 8
11   -class UsernameSearch(object):
  9 +class UsernameSearch:
12 10 """The User object may not be auth.User, so we need to provide
13 11 a mechanism for issuing the equivalent of a .filter(user__username=...)
14 12 search in CommentAdmin.
... ... @@ -43,7 +41,7 @@ class CommentsAdmin(admin.ModelAdmin):
43 41 actions = ["flag_comments", "approve_comments", "remove_comments"]
44 42
45 43 def get_actions(self, request):
46   - actions = super(CommentsAdmin, self).get_actions(request)
  44 + actions = super().get_actions(request)
47 45 # Only superusers should be able to delete the comments from the DB.
48 46 if not request.user.is_superuser and 'delete_selected' in actions:
49 47 actions.pop('delete_selected')
... ...
... ... @@ -10,7 +10,7 @@ class LatestCommentFeed(Feed):
10 10
11 11 def __call__(self, request, *args, **kwargs):
12 12 self.site = get_current_site(request)
13   - return super(LatestCommentFeed, self).__call__(request, *args, **kwargs)
  13 + return super().__call__(request, *args, **kwargs)
14 14
15 15 def title(self):
16 16 return _("%(site_name)s comments") % dict(site_name=self.site.name)
... ...
... ... @@ -30,7 +30,7 @@ class CommentSecurityForm(forms.Form):
30 30 if initial is None:
31 31 initial = {}
32 32 initial.update(self.generate_security_data())
33   - super(CommentSecurityForm, self).__init__(data=data, initial=initial, **kwargs)
  33 + super().__init__(data=data, initial=initial, **kwargs)
34 34
35 35 def security_errors(self):
36 36 """Return just those errors associated with security"""
... ...
1   -# -*- coding: utf-8 -*-
2   -from __future__ import unicode_literals
3   -
4 1 from django.db import models, migrations
5 2 from django.conf import settings
6 3
... ...
1   -# -*- coding: utf-8 -*-
2   -from __future__ import unicode_literals
3   -
4 1 from django.db import models, migrations
5 2
6 3
... ...
1   -# -*- coding: utf-8 -*-
2   -from __future__ import unicode_literals
3   -
4 1 from django.db import models, migrations
5 2
6 3
... ...
... ... @@ -2,7 +2,6 @@ from django.conf import settings
2 2 from django.db import models
3 3 from django.utils import timezone
4 4 from django.utils.translation import gettext_lazy as _
5   -from six import python_2_unicode_compatible
6 5
7 6 from .abstracts import (
8 7 COMMENT_MAX_LENGTH, BaseCommentAbstractModel, CommentAbstractModel,
... ... @@ -14,7 +13,6 @@ class Comment(CommentAbstractModel):
14 13 db_table = "django_comments"
15 14
16 15
17   -@python_2_unicode_compatible
18 16 class CommentFlag(models.Model):
19 17 """
20 18 Records a flag on a comment. This is intentionally flexible; right now, a
... ... @@ -59,4 +57,4 @@ class CommentFlag(models.Model):
59 57 def save(self, *args, **kwargs):
60 58 if self.flag_date is None:
61 59 self.flag_date = timezone.now()
62   - super(CommentFlag, self).save(*args, **kwargs)
  60 + super().save(*args, **kwargs)
... ...
... ... @@ -86,7 +86,7 @@ class NotModerated(Exception):
86 86 pass
87 87
88 88
89   -class CommentModerator(object):
  89 +class CommentModerator:
90 90 """
91 91 Encapsulates comment-moderation options for a given model.
92 92
... ... @@ -257,7 +257,7 @@ class CommentModerator(object):
257 257 send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)
258 258
259 259
260   -class Moderator(object):
  260 +class Moderator:
261 261 """
262 262 Handles moderation of a set of models.
263 263
... ...
1   -from __future__ import absolute_import
2   -
3 1 from django import http
4 2 from django.apps import apps
5 3 from django.conf import settings
... ... @@ -24,7 +22,7 @@ class CommentPostBadRequest(http.HttpResponseBadRequest):
24 22 """
25 23
26 24 def __init__(self, why):
27   - super(CommentPostBadRequest, self).__init__()
  25 + super().__init__()
28 26 if settings.DEBUG:
29 27 self.content = render_to_string("comments/400-debug.html", {"why": why})
30 28
... ...
1   -from __future__ import absolute_import
2   -
3 1 from django.contrib.auth.decorators import login_required, permission_required
4 2 from django.contrib.sites.shortcuts import get_current_site
5 3 from django.shortcuts import get_object_or_404, render
... ...
... ... @@ -3,11 +3,7 @@ A few bits of helper functions for comment views.
3 3 """
4 4
5 5 import textwrap
6   -
7   -try:
8   - from urllib.parse import urlencode
9   -except ImportError: # Python 2
10   - from urllib import urlencode
  6 +from urllib.parse import urlencode
11 7
12 8 from django.http import HttpResponseRedirect
13 9 from django.shortcuts import render, resolve_url
... ...
... ... @@ -87,7 +87,7 @@ field::
87 87
88 88 def get_comment_create_data(self, **kwargs):
89 89 # Use the data of the superclass, and add in the title field
90   - data = super(CommentFormWithTitle, self).get_comment_create_data(**kwargs)
  90 + data = super().get_comment_create_data(**kwargs)
91 91 data['title'] = self.cleaned_data['title']
92 92 return data
93 93
... ...
... ... @@ -33,7 +33,6 @@ setup(
33 33 'License :: OSI Approved :: BSD License',
34 34 'Operating System :: OS Independent',
35 35 'Programming Language :: Python',
36   - 'Programming Language :: Python :: 2.7',
37 36 'Programming Language :: Python :: 3',
38 37 'Programming Language :: Python :: 3.6',
39 38 'Programming Language :: Python :: 3.7',
... ...
... ... @@ -3,13 +3,9 @@ Comments may be attached to any object. See the comment documentation for
3 3 more information.
4 4 """
5 5
6   -from __future__ import unicode_literals
7   -
8 6 from django.db import models
9   -from six import python_2_unicode_compatible
10 7
11 8
12   -@python_2_unicode_compatible
13 9 class Author(models.Model):
14 10 first_name = models.CharField(max_length=30)
15 11 last_name = models.CharField(max_length=30)
... ... @@ -18,7 +14,6 @@ class Author(models.Model):
18 14 return '%s %s' % (self.first_name, self.last_name)
19 15
20 16
21   -@python_2_unicode_compatible
22 17 class Article(models.Model):
23 18 author = models.ForeignKey(Author, on_delete=models.CASCADE)
24 19 headline = models.CharField(max_length=100)
... ... @@ -27,7 +22,6 @@ class Article(models.Model):
27 22 return self.headline
28 23
29 24
30   -@python_2_unicode_compatible
31 25 class Entry(models.Model):
32 26 title = models.CharField(max_length=250)
33 27 body = models.TextField()
... ...
1   -from __future__ import absolute_import
2   -
3 1 from django.contrib.auth.models import User
4 2 from django.contrib.contenttypes.models import ContentType
5 3 from django.contrib.sites.models import Site
... ...
1   -from __future__ import absolute_import
2   -
3 1 from django.core.exceptions import ImproperlyConfigured
4 2 from django.test.utils import modify_settings, override_settings
5 3
... ...
1   -from __future__ import absolute_import
2   -
3 1 import time
4 2
5 3 from django.conf import settings
... ... @@ -15,7 +13,7 @@ from testapp.models import Article
15 13 class CommentFormTests(CommentTestCase):
16 14
17 15 def setUp(self):
18   - super(CommentFormTests, self).setUp()
  16 + super().setUp()
19 17 self.site_2 = Site.objects.create(id=settings.SITE_ID + 1,
20 18 domain="testserver", name="testserver")
21 19
... ...
1   -from __future__ import absolute_import
2   -
3 1 from django.core import mail
4 2 from django.test.utils import override_settings
5 3
... ...
1   -from __future__ import absolute_import, unicode_literals
2   -
3 1 from django.conf import settings
4 2 from django.contrib.auth.models import User
5 3
... ...
1   -from __future__ import absolute_import
2   -
3 1 from xml.etree import ElementTree as ET
4 2
5 3 from django.conf import settings
... ...
1   -from __future__ import absolute_import
2   -
3 1 from django_comments.models import Comment
4 2
5 3 from . import CommentTestCase
... ...
1   -from __future__ import absolute_import, unicode_literals
2   -
3 1 from django.contrib.auth.models import User, Permission
4 2 from django.contrib.contenttypes.models import ContentType
5 3 from django.test.utils import override_settings
... ... @@ -268,7 +266,7 @@ class ApproveViewTests(CommentTestCase):
268 266 class AdminActionsTests(CommentTestCase):
269 267
270 268 def setUp(self):
271   - super(AdminActionsTests, self).setUp()
  269 + super().setUp()
272 270
273 271 # Make "normaluser" a moderator
274 272 u = User.objects.get(username="normaluser")
... ...
1   -from __future__ import absolute_import
2   -
3 1 from django.conf import settings
4 2 from django.contrib.contenttypes.models import ContentType
5 3 from django.contrib.sites.models import Site
... ... @@ -17,7 +15,7 @@ from . import CommentTestCase
17 15 class CommentTemplateTagTests(CommentTestCase):
18 16
19 17 def setUp(self):
20   - super(CommentTemplateTagTests, self).setUp()
  18 + super().setUp()
21 19 self.site_2 = Site.objects.create(id=settings.SITE_ID + 1,
22 20 domain="testserver", name="testserver")
23 21
... ...
1   -from __future__ import absolute_import
2   -
3 1 from django.conf.urls import url
4 2 from django.contrib.contenttypes.views import shortcut
5 3
... ...
1 1 [tox]
2 2 envlist =
3   - py{27,34,35,36,37}-django111
  3 + py{34,35,36,37}-django111
4 4 py3{4,5,6,7}-django20
5 5 py3{5,6,7}-django21
6 6 py3{5,6,7}-django22
... ... @@ -9,7 +9,6 @@ envlist =
9 9
10 10 [testenv]
11 11 basepython =
12   - py27: python2.7
13 12 py34: python3.4
14 13 py35: python3.5
15 14 py36: python3.6
... ...
Please register or login to post a comment