Skip to content

Commit

Permalink
clean up python 2 compatible changes (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
M. Zulqarnain authored Aug 20, 2020
1 parent 0111cd9 commit 0c732fa
Show file tree
Hide file tree
Showing 29 changed files with 29 additions and 51 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ Unreleased

*

[1.0.0] - 2020-03-18
[1.2.0] - 2020-08-20
~~~~~~~~~~~~~~~~~~~~

Removed
+++++++

* Removed code related to Python 2


[1.1.0] - 2020-05-07
~~~~~~~~~~~~~~~~~~~~

Added
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# pylint: disable=invalid-name
"""
django-user-tasks documentation build configuration file.
Expand Down
1 change: 0 additions & 1 deletion schema/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
URLs for REST API schema generation.
"""
Expand Down
6 changes: 2 additions & 4 deletions schema/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Views for rendering REST API schema documents.
"""

import io
import logging
import os

Expand All @@ -26,10 +24,10 @@ def render(self, data, accepted_media_type=None, renderer_context=None):
Render the appropriate Open API JSON file.
"""
if 'SWAGGER_JSON_PATH' in os.environ:
with io.open(os.environ['SWAGGER_JSON_PATH'], 'rb') as f:
with open(os.environ['SWAGGER_JSON_PATH'], 'rb') as f:
return f.read()
else:
return super(ConditionalOpenAPIRenderer, self).render(data, accepted_media_type, renderer_context)
return super().render(data, accepted_media_type, renderer_context)


@api_view()
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable=C0111,W6005,W6100


Expand Down
1 change: 0 additions & 1 deletion test_urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
URLs for user_tasks test suite.
"""
Expand Down
3 changes: 1 addition & 2 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for the ``django-user-tasks`` admin module.
"""
Expand All @@ -14,7 +13,7 @@ class AdminTestCase(TestCase):
Tests for the ``user_tasks`` application's Django admin pages.
"""
def setUp(self):
super(AdminTestCase, self).setUp()
super().setUp()
self.user = User.objects.create_user(
username='tester',
email='[email protected]',
Expand Down
5 changes: 2 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for the `django-user-tasks` models module.
"""
Expand All @@ -26,7 +25,7 @@ class TestUserTaskStatus(TestCase):

@classmethod
def setUpTestData(cls):
super(TestUserTaskStatus, cls).setUpTestData()
super().setUpTestData()
cls.user = User.objects.create_user('test_user', '[email protected]', 'password')

def test_cancel_parent(self):
Expand Down Expand Up @@ -206,7 +205,7 @@ class TestUserTaskArtifact(TestCase):

@classmethod
def setUpTestData(cls):
super(TestUserTaskArtifact, cls).setUpTestData()
super().setUpTestData()
cls.user = User.objects.create_user('test_user', '[email protected]', 'password')

def test_file_string(self):
Expand Down
9 changes: 4 additions & 5 deletions tests/test_rest_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for the ``django-user-tasks`` REST API.
"""
Expand Down Expand Up @@ -47,17 +46,17 @@ class TestRestApi(APITestCase):

@classmethod
def setUpClass(cls):
super(TestRestApi, cls).setUpClass()
super().setUpClass()
add_rules()

@classmethod
def tearDownClass(cls):
super(TestRestApi, cls).tearDownClass()
super().tearDownClass()
rules.rulesets.default_rules.clear()

@classmethod
def setUpTestData(cls):
super(TestRestApi, cls).setUpTestData()
super().setUpTestData()
cls.user = User.objects.create_user('test_user', '[email protected]', 'password')
cls.superuser = User.objects.create_superuser('admin', '[email protected]', 'password')
cls.other_user = User.objects.create_user('other_user', '[email protected]', 'password')
Expand All @@ -72,7 +71,7 @@ def setUpTestData(cls):
UserTaskStatus.objects.filter(pk=cls.older_status.id).update(created=yesterday, modified=yesterday)

def setUp(self):
super(TestRestApi, self).setUp()
super().setUp()
self.status.refresh_from_db()
self.older_status.refresh_from_db()

Expand Down
7 changes: 3 additions & 4 deletions tests/test_serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for the REST API model serializers.
"""
Expand Down Expand Up @@ -34,7 +33,7 @@ class TestStatusSerializer(TestCase):

@classmethod
def setUpTestData(cls):
super(TestStatusSerializer, cls).setUpTestData()
super().setUpTestData()
cls.user = User.objects.create_user('test_user', '[email protected]', 'password')

def test_output(self):
Expand Down Expand Up @@ -81,13 +80,13 @@ class TestArtifactSerializer(TestCase):

@classmethod
def setUpTestData(cls):
super(TestArtifactSerializer, cls).setUpTestData()
super().setUpTestData()
user = User.objects.create_user('test_user', '[email protected]', 'password')
cls.status = UserTaskStatus.objects.create(user=user, task_id=str(uuid4()), name='SampleTask', total_steps=4)

@classmethod
def tearDownClass(cls):
super(TestArtifactSerializer, cls).tearDownClass()
super().tearDownClass()
# Clean up temp files
shutil.rmtree(settings.MEDIA_ROOT)

Expand Down
9 changes: 4 additions & 5 deletions tests/test_signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for the ``django-user-tasks`` Celery signal handlers and Django signal.
"""
Expand Down Expand Up @@ -99,12 +98,12 @@ class TestCreateUserTask(TestCase):
"""

def tearDown(self):
super(TestCreateUserTask, self).tearDown()
super().tearDown()
SIGNAL_DATA.clear()

@classmethod
def setUpTestData(cls):
super(TestCreateUserTask, cls).setUpTestData()
super().setUpTestData()
cls.user = User.objects.create_user('test_user', '[email protected]', 'password')

def test_create_user_task(self):
Expand Down Expand Up @@ -380,12 +379,12 @@ class TestStatusChanges(TestCase):
"""

def tearDown(self):
super(TestStatusChanges, self).tearDown()
super().tearDown()
SIGNAL_DATA.clear()

@classmethod
def setUpTestData(cls):
super(TestStatusChanges, cls).setUpTestData()
super().setUpTestData()
cls.user = User.objects.create_user('test_user', '[email protected]', 'password')

def test_canceled_before_execution(self):
Expand Down
5 changes: 2 additions & 3 deletions tests/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for the user_tasks subclasses of celery.Task.
"""
Expand Down Expand Up @@ -67,7 +66,7 @@ class TestUserTasks(TestCase):

@classmethod
def setUpTestData(cls):
super(TestUserTasks, cls).setUpTestData()
super().setUpTestData()
cls.user = User.objects.create_user('test_user', '[email protected]', 'password')

def test_generate_name_omitted(self):
Expand Down Expand Up @@ -114,7 +113,7 @@ class TestPurgeOldUserTasks(TestCase):

@classmethod
def setUpTestData(cls):
super(TestPurgeOldUserTasks, cls).setUpTestData()
super().setUpTestData()
cls.user = User.objects.create_user('test_user', '[email protected]', 'password')

def test_old_data(self):
Expand Down
2 changes: 1 addition & 1 deletion user_tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from django.dispatch import Signal

__version__ = '1.1.0'
__version__ = '1.2.0'

default_app_config = 'user_tasks.apps.UserTasksConfig' # pylint: disable=invalid-name

Expand Down
1 change: 0 additions & 1 deletion user_tasks/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Django admin configuration for the ``django-user-tasks`` models.
"""
Expand Down
1 change: 0 additions & 1 deletion user_tasks/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
user_tasks Django application initialization.
"""
Expand Down
1 change: 0 additions & 1 deletion user_tasks/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Custom Django settings for django-user-tasks.
"""
Expand Down
1 change: 0 additions & 1 deletion user_tasks/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Custom exception classes.
"""
Expand Down
1 change: 0 additions & 1 deletion user_tasks/filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Optional Django REST Framework filter backends for the ``django-user-tasks`` REST API.
"""
Expand Down
1 change: 0 additions & 1 deletion user_tasks/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.1 on 2016-09-07 20:22


Expand Down
1 change: 0 additions & 1 deletion user_tasks/migrations/0002_artifact_file_storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2016-12-05 16:12


Expand Down
1 change: 0 additions & 1 deletion user_tasks/migrations/0003_url_max_length.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-29 13:03


Expand Down
1 change: 0 additions & 1 deletion user_tasks/migrations/0004_url_textfield.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-29 17:51


Expand Down
4 changes: 0 additions & 4 deletions user_tasks/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Database models for user_tasks.
"""
Expand All @@ -13,7 +12,6 @@
from django.db import models, transaction
from django.db.models import Q
from django.db.models.expressions import F
from django.utils.encoding import python_2_unicode_compatible
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _

Expand All @@ -30,7 +28,6 @@
# See https://github.com/landscapeio/pylint-django/issues/35 for more details


@python_2_unicode_compatible
class UserTaskStatus(TimeStampedModel):
"""
The current status of an asynchronous task running on behalf of a particular user.
Expand Down Expand Up @@ -226,7 +223,6 @@ def __str__(self):
return '<UserTaskStatus: {}>'.format(self.name)


@python_2_unicode_compatible
class UserTaskArtifact(TimeStampedModel):
"""
An artifact (or error message) generated for a user by an asynchronous task.
Expand Down
1 change: 0 additions & 1 deletion user_tasks/rules.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Sample implementation of authorization rules for the ``django-user-tasks`` permissions.
Expand Down
1 change: 0 additions & 1 deletion user_tasks/serializers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
REST API serialization classes.
"""
Expand Down
1 change: 0 additions & 1 deletion user_tasks/signals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Celery signal handlers and custom Django signal.
"""
Expand Down
1 change: 0 additions & 1 deletion user_tasks/tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Celery task abstract base classes.
"""
Expand Down
1 change: 0 additions & 1 deletion user_tasks/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
URLs for user_tasks.
"""
Expand Down
1 change: 0 additions & 1 deletion user_tasks/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
REST API endpoints.
"""
Expand Down

0 comments on commit 0c732fa

Please sign in to comment.