diff --git a/openedx/core/djangoapps/waffle_utils/__init__.py b/openedx/core/djangoapps/waffle_utils/__init__.py index 276e72e75c..88531aaf87 100644 --- a/openedx/core/djangoapps/waffle_utils/__init__.py +++ b/openedx/core/djangoapps/waffle_utils/__init__.py @@ -60,6 +60,7 @@ can't yet be deleted, for example if there are straggling course overrides. than implicit. """ +from __future__ import absolute_import import crum import logging from abc import ABCMeta @@ -74,7 +75,7 @@ from openedx.core.lib.cache_utils import get_cache as get_request_cache log = logging.getLogger(__name__) -class WaffleNamespace(object): +class WaffleNamespace(six.with_metaclass(ABCMeta, object)): """ A base class for a request cached namespace for waffle flags/switches. @@ -82,7 +83,6 @@ class WaffleNamespace(object): (e.g. "course_experience"), and can be used to work with a set of flags or switches that will all share this namespace. """ - __metaclass__ = ABCMeta def __init__(self, name, log_prefix=None): """ @@ -216,14 +216,13 @@ class WaffleSwitch(object): yield -class WaffleFlagNamespace(WaffleNamespace): +class WaffleFlagNamespace(six.with_metaclass(ABCMeta, WaffleNamespace)): """ Provides a single namespace for a set of waffle flags. All namespaced flag values are stored in a single request cache containing all flags for all namespaces. """ - __metaclass__ = ABCMeta @property def _cached_flags(self): @@ -371,7 +370,7 @@ class CourseWaffleFlag(WaffleFlag): """ # Import is placed here to avoid model import at project startup. from .models import WaffleFlagCourseOverrideModel - cache_key = u'{}.{}'.format(namespaced_flag_name, unicode(course_key)) + cache_key = u'{}.{}'.format(namespaced_flag_name, six.text_type(course_key)) force_override = self.waffle_namespace._cached_flags.get(cache_key) if force_override is None: diff --git a/openedx/core/djangoapps/waffle_utils/admin.py b/openedx/core/djangoapps/waffle_utils/admin.py index 05cad5175c..59258f2c1e 100644 --- a/openedx/core/djangoapps/waffle_utils/admin.py +++ b/openedx/core/djangoapps/waffle_utils/admin.py @@ -1,6 +1,7 @@ """ Django admin page for waffle utils models """ +from __future__ import absolute_import from django.contrib import admin from config_models.admin import KeyedConfigurationModelAdmin diff --git a/openedx/core/djangoapps/waffle_utils/forms.py b/openedx/core/djangoapps/waffle_utils/forms.py index 21c69cf924..bed1101baa 100644 --- a/openedx/core/djangoapps/waffle_utils/forms.py +++ b/openedx/core/djangoapps/waffle_utils/forms.py @@ -1,6 +1,7 @@ """ Defines a form for providing validation of subsection grade templates. """ +from __future__ import absolute_import from django import forms from openedx.core.lib.courses import clean_course_id diff --git a/openedx/core/djangoapps/waffle_utils/migrations/0001_initial.py b/openedx/core/djangoapps/waffle_utils/migrations/0001_initial.py index bb9ca54de6..bc756df095 100644 --- a/openedx/core/djangoapps/waffle_utils/migrations/0001_initial.py +++ b/openedx/core/djangoapps/waffle_utils/migrations/0001_initial.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from __future__ import absolute_import import django.db.models.deletion from django.conf import settings from django.db import migrations, models diff --git a/openedx/core/djangoapps/waffle_utils/models.py b/openedx/core/djangoapps/waffle_utils/models.py index 792b139d54..4f84b684f6 100644 --- a/openedx/core/djangoapps/waffle_utils/models.py +++ b/openedx/core/djangoapps/waffle_utils/models.py @@ -1,6 +1,7 @@ """ Models for configuring waffle utils. """ +from __future__ import absolute_import from django.db.models import CharField from django.utils.translation import ugettext_lazy as _ from model_utils import Choices diff --git a/openedx/core/djangoapps/waffle_utils/tests/test_init.py b/openedx/core/djangoapps/waffle_utils/tests/test_init.py index bcac166504..8d005c0dca 100644 --- a/openedx/core/djangoapps/waffle_utils/tests/test_init.py +++ b/openedx/core/djangoapps/waffle_utils/tests/test_init.py @@ -1,6 +1,7 @@ """ Tests for waffle utils features. """ +from __future__ import absolute_import import crum import ddt from django.test import TestCase diff --git a/openedx/core/djangoapps/waffle_utils/tests/test_models.py b/openedx/core/djangoapps/waffle_utils/tests/test_models.py index b2aab23c82..965eea16f3 100644 --- a/openedx/core/djangoapps/waffle_utils/tests/test_models.py +++ b/openedx/core/djangoapps/waffle_utils/tests/test_models.py @@ -1,6 +1,7 @@ """ Tests for waffle utils models. """ +from __future__ import absolute_import from ddt import data, ddt, unpack from django.test import TestCase from edx_django_utils.cache import RequestCache diff --git a/openedx/core/djangoapps/waffle_utils/tests/test_testutils.py b/openedx/core/djangoapps/waffle_utils/tests/test_testutils.py index b9da185335..8a307b0286 100644 --- a/openedx/core/djangoapps/waffle_utils/tests/test_testutils.py +++ b/openedx/core/djangoapps/waffle_utils/tests/test_testutils.py @@ -2,6 +2,7 @@ Tests for waffle utils test utilities. """ +from __future__ import absolute_import import crum from django.test import TestCase from django.test.client import RequestFactory diff --git a/openedx/core/djangoapps/waffle_utils/testutils.py b/openedx/core/djangoapps/waffle_utils/testutils.py index b27de92c3c..03487dc4f0 100644 --- a/openedx/core/djangoapps/waffle_utils/testutils.py +++ b/openedx/core/djangoapps/waffle_utils/testutils.py @@ -2,6 +2,7 @@ Test utilities for waffle utilities. """ +from __future__ import absolute_import from waffle.testutils import override_flag # Can be used with FilteredQueryCountMixin.assertNumQueries() to blacklist