INCR-163 python-modernize on openedx/core/djangoapps/waffle_utils (#20469)

This commit is contained in:
aliciaerwin
2019-05-09 11:54:17 -04:00
committed by Jeremy Bowman
parent e01fa86755
commit 6d3e3bf876
9 changed files with 12 additions and 5 deletions

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,6 +1,7 @@
"""
Tests for waffle utils features.
"""
from __future__ import absolute_import
import crum
import ddt
from django.test import TestCase

View File

@@ -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

View File

@@ -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

View File

@@ -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