diff --git a/openedx/core/djangoapps/util/apps.py b/openedx/core/djangoapps/util/apps.py index d3e5b02ba4..83ecfe3905 100644 --- a/openedx/core/djangoapps/util/apps.py +++ b/openedx/core/djangoapps/util/apps.py @@ -1,6 +1,7 @@ """ Configuration for the openedx.core.djangoapps.util Django application """ +from __future__ import absolute_import from django.apps import AppConfig diff --git a/openedx/core/djangoapps/util/forms.py b/openedx/core/djangoapps/util/forms.py index bb60de9354..8425e665e2 100644 --- a/openedx/core/djangoapps/util/forms.py +++ b/openedx/core/djangoapps/util/forms.py @@ -1,6 +1,7 @@ """ Custom forms-related types """ +from __future__ import absolute_import from django.core.exceptions import ValidationError from django.forms import Field, MultipleHiddenInput, NullBooleanField, Select diff --git a/openedx/core/djangoapps/util/log_utils.py b/openedx/core/djangoapps/util/log_utils.py index 1e41fb51f4..1d71b11f63 100644 --- a/openedx/core/djangoapps/util/log_utils.py +++ b/openedx/core/djangoapps/util/log_utils.py @@ -3,7 +3,10 @@ Django-based logging utilities UserIdFilter: A logging.Filter that adds userid to the logging context """ +from __future__ import absolute_import + from logging import Filter + from crum import get_current_user diff --git a/openedx/core/djangoapps/util/ratelimit.py b/openedx/core/djangoapps/util/ratelimit.py index e82183609b..11a8d7bab5 100644 --- a/openedx/core/djangoapps/util/ratelimit.py +++ b/openedx/core/djangoapps/util/ratelimit.py @@ -1,3 +1,8 @@ +""" +Code to get ip from request. +""" +from __future__ import absolute_import + from ipware.ip import get_ip diff --git a/openedx/core/djangoapps/util/row_delete.py b/openedx/core/djangoapps/util/row_delete.py index 1f6c183810..c813e42cb2 100644 --- a/openedx/core/djangoapps/util/row_delete.py +++ b/openedx/core/djangoapps/util/row_delete.py @@ -1,10 +1,12 @@ """ Code to delete rows from a table within a Django mgmt command using best practices. """ +from __future__ import absolute_import import logging import time -from django.core.management.base import CommandError, BaseCommand + +from django.core.management.base import BaseCommand, CommandError from django.db import transaction log = logging.getLogger(__name__) diff --git a/openedx/core/djangoapps/util/signals.py b/openedx/core/djangoapps/util/signals.py index 4ffd54aa42..71cfbeb050 100644 --- a/openedx/core/djangoapps/util/signals.py +++ b/openedx/core/djangoapps/util/signals.py @@ -2,6 +2,8 @@ Signal handler for exceptions. """ # pylint: disable=unused-argument +from __future__ import absolute_import + import logging from celery.signals import task_postrun diff --git a/openedx/core/djangoapps/util/testing.py b/openedx/core/djangoapps/util/testing.py index c7c15a8ffc..fbba29c400 100644 --- a/openedx/core/djangoapps/util/testing.py +++ b/openedx/core/djangoapps/util/testing.py @@ -1,17 +1,19 @@ """ Mixins for setting up particular course structures (such as split tests or cohorted content) """ +from __future__ import absolute_import from datetime import datetime + from pytz import UTC -from openedx.core.djangoapps.django_comment_common.models import Role -from openedx.core.djangoapps.django_comment_common.utils import seed_permissions_roles from openedx.core.djangoapps.course_groups.models import CourseUserGroupPartitionGroup from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory +from openedx.core.djangoapps.django_comment_common.models import Role +from openedx.core.djangoapps.django_comment_common.utils import seed_permissions_roles from openedx.core.djangoapps.user_api.tests.factories import UserCourseTagFactory -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory -from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.partitions.partitions import UserPartition, Group from student.tests.factories import CourseEnrollmentFactory, UserFactory +from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase +from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.partitions.partitions import Group, UserPartition class ContentGroupTestCase(ModuleStoreTestCase): diff --git a/openedx/core/djangoapps/util/user_messages.py b/openedx/core/djangoapps/util/user_messages.py index efb501ad07..271d755688 100644 --- a/openedx/core/djangoapps/util/user_messages.py +++ b/openedx/core/djangoapps/util/user_messages.py @@ -13,13 +13,16 @@ There are two common use cases: the message will be shown on the subsequent page. This is typically used to show a success message to the use. """ +from __future__ import absolute_import from abc import abstractmethod from enum import Enum +import six from django.contrib import messages from django.utils.translation import ugettext as _ -from openedx.core.djangolib.markup import Text, HTML + +from openedx.core.djangolib.markup import HTML, Text class UserMessageType(Enum): @@ -172,7 +175,7 @@ class UserMessageCollection(): """ return UserMessage( type=_get_message_type_for_level(message.level), - message_html=unicode(message.message), + message_html=six.text_type(message.message), ) django_messages = messages.get_messages(request) diff --git a/openedx/core/djangoapps/util/user_utils.py b/openedx/core/djangoapps/util/user_utils.py index 18ecb9f578..d5de59a9af 100644 --- a/openedx/core/djangoapps/util/user_utils.py +++ b/openedx/core/djangoapps/util/user_utils.py @@ -1,6 +1,7 @@ """ Custom user-related utility code. """ +from __future__ import absolute_import from django.contrib.auth.models import AnonymousUser