diff --git a/djadmin2/actions.py b/djadmin2/actions.py index 507d19c..ac7b782 100644 --- a/djadmin2/actions.py +++ b/djadmin2/actions.py @@ -49,7 +49,7 @@ class BaseListAction(Admin2ModelMixin, TemplateView): objects_name = options.verbose_name_plural self.objects_name = force_str(objects_name) - super(BaseListAction, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def get_queryset(self): """ Replaced `get_queryset` from `Admin2ModelMixin`""" @@ -85,7 +85,7 @@ class BaseListAction(Admin2ModelMixin, TemplateView): """ Utility method when you want to display nested objects (such as during a bulk update/delete) """ - context = super(BaseListAction, self).get_context_data() + context = super().get_context_data() def _format_callback(obj): opts = utils.model_options(obj) @@ -108,7 +108,7 @@ class BaseListAction(Admin2ModelMixin, TemplateView): def get(self, request): if self.item_count > 0: - return super(BaseListAction, self).get(request) + return super().get(request) message = _(self.empty_message) messages.add_message(request, messages.INFO, message) @@ -160,7 +160,7 @@ class DeleteSelectedAction(BaseListAction): def post(self, request): if request.POST.get('confirmed'): - super(DeleteSelectedAction, self).post(request) + super().post(request) else: # The user has not confirmed that they want to delete the # objects, so render a template asking for their confirmation. diff --git a/djadmin2/apiviews.py b/djadmin2/apiviews.py index 513e880..54ba0f3 100644 --- a/djadmin2/apiviews.py +++ b/djadmin2/apiviews.py @@ -17,7 +17,7 @@ class Admin2APISerializer(serializers.HyperlinkedModelSerializer): __unicode__ = fields.ReadOnlyField(source='__str__') def get_extra_kwargs(self): - extra_kwargs = super(Admin2APISerializer, self).get_extra_kwargs() + extra_kwargs = super().get_extra_kwargs() extra_kwargs.update({ 'url': {'view_name': self._get_default_view_name(self.Meta.model)} }) @@ -56,7 +56,7 @@ class Admin2APIMixin(Admin2Mixin): fields = '__all__' return ModelAPISerilizer - return super(Admin2APIMixin, self).get_serializer_class() + return super().get_serializer_class() class IndexAPIView(Admin2APIMixin, APIView): diff --git a/djadmin2/core.py b/djadmin2/core.py index 8754e38..e284f72 100644 --- a/djadmin2/core.py +++ b/djadmin2/core.py @@ -14,7 +14,7 @@ from . import utils from . import views -class Admin2(object): +class Admin2: """ The base Admin2 object. It keeps a registry of all registered Models and collects the urls of their @@ -137,7 +137,7 @@ class Admin2(object): for object_admin in self.registry.values(): if object_admin.name == name: return object_admin - raise ValueError(u"No object admin found with name {}".format(repr(name))) + raise ValueError("No object admin found with name {}".format(repr(name))) def get_index_kwargs(self): return { diff --git a/djadmin2/tests/test_actions.py b/djadmin2/tests/test_actions.py index 10b8723..9e5f4f6 100644 --- a/djadmin2/tests/test_actions.py +++ b/djadmin2/tests/test_actions.py @@ -5,7 +5,7 @@ from ..actions import get_description from .models import Thing -class TestAction(object): +class TestAction: description = "Test Action Class" diff --git a/djadmin2/tests/test_admin2tags.py b/djadmin2/tests/test_admin2tags.py index f4fab24..f125123 100644 --- a/djadmin2/tests/test_admin2tags.py +++ b/djadmin2/tests/test_admin2tags.py @@ -73,12 +73,12 @@ class TagsTests(TestCase): formset = TagsTestFormSet() self.assertEqual( admin2_tags.formset_visible_fieldlist(formset), - [u'Visible 1', u'Visible 2'] + ['Visible 1', 'Visible 2'] ) def test_verbose_name_for(self): app_verbose_names = { - u'app_one_label': 'App One Verbose Name', + 'app_one_label': 'App One Verbose Name', } self.assertEqual( "App One Verbose Name", diff --git a/djadmin2/tests/test_types.py b/djadmin2/tests/test_types.py index 280142b..71ad316 100644 --- a/djadmin2/tests/test_types.py +++ b/djadmin2/tests/test_types.py @@ -6,7 +6,7 @@ from ..core import Admin2 from .models import BigThing -class ModelAdmin(object): +class ModelAdmin: model_admin_attributes = ['a', 'b', 'c'] a = 1 # covered b = 2 # covered @@ -73,7 +73,7 @@ class ModelAdminTest(TestCase): admin_instance.get_urls() except TypeError as e: - message = u"Cannot instantiate admin view " \ + message = "Cannot instantiate admin view " \ '"ModelAdmin2.None". The error that got raised was: ' \ "'NoneType' object has no attribute 'as_view'" self.assertEqual(e.args[0], message) diff --git a/djadmin2/tests/test_utils.py b/djadmin2/tests/test_utils.py index 1264b82..68f8c9d 100644 --- a/djadmin2/tests/test_utils.py +++ b/djadmin2/tests/test_utils.py @@ -119,7 +119,7 @@ class UtilsTest(TestCase): ) def test_get_attr_callable(self): - class Klass(object): + class Klass: def hello(self): return "hello" @@ -129,7 +129,7 @@ class UtilsTest(TestCase): ) def test_get_attr_str(self): - class Klass(object): + class Klass: def __str__(self): return "str" @@ -142,7 +142,7 @@ class UtilsTest(TestCase): ) def test_get_attr(self): - class Klass(object): + class Klass: attr = "value" self.assertEqual(