Repository: django-compressor/django-compressor

Issue:
Remove COMPRESS_*_FILTERS settings
Deprecated in https://github.com/django-compressor/django-compressor/issues/985

We'll be able to remove those in 3.0, I'll make an intermediate version in the meantime.


Discussion:

Resolving patch:
diff --git a/compressor/conf.py b/compressor/conf.py
--- a/compressor/conf.py
+++ b/compressor/conf.py
@@ -1,5 +1,4 @@
 import os
-import warnings
 from django.conf import settings
 from django.core.exceptions import ImproperlyConfigured
 from django.template.utils import InvalidTemplateEngineError
@@ -7,15 +6,6 @@
 from appconf import AppConf
 
 
-default_filters = {
-    'css': [
-        'compressor.filters.css_default.CssAbsoluteFilter',
-        'compressor.filters.cssmin.rCSSMinFilter'
-    ],
-    'js': ['compressor.filters.jsmin.rJSMinFilter']
-}
-
-
 class CompressorConf(AppConf):
     # Main switch
     ENABLED = not settings.DEBUG
@@ -36,10 +26,13 @@ class CompressorConf(AppConf):
     URL = None
     ROOT = None
 
-    # Filters are resolved in configure()
-    FILTERS = {}
-    CSS_FILTERS = None
-    JS_FILTERS = None
+    FILTERS = {
+        'css': [
+            'compressor.filters.css_default.CssAbsoluteFilter',
+            'compressor.filters.cssmin.rCSSMinFilter'
+        ],
+        'js': ['compressor.filters.jsmin.rJSMinFilter']
+    }
 
     CSS_HASHING_METHOD = 'mtime'
 
@@ -145,31 +138,3 @@ def configure_precompilers(self, value):
                                        "must be a list or tuple. Check for "
                                        "missing commas.")
         return value
-
-    def configure(self):
-        data = self.configured_data
-        for kind in {'css', 'js'}:
-            setting_name = '%s_FILTERS' % kind.upper()
-            filters = data.pop(setting_name)
-            if filters is not None:
-                warnings.warn(
-                    "COMPRESS_{setting_name} setting is deprecated and will "
-                    "be removed in django-compressor 3.0. "
-                    "Use COMPRESS_FILTERS instead."
-                    .format(setting_name=setting_name), DeprecationWarning)
-                if kind in data['FILTERS']:
-                    raise ImproperlyConfigured(
-                        "The setting {kind_setting} "
-                        "conflicts with {main_setting}['{kind}']. "
-                        "Remove either setting and update the other to "
-                        "the correct list of filters for {kind} resources"
-                        ", we recommend you keep the latter."
-                        .format(
-                            kind_setting=self._meta.prefixed_name(setting_name),
-                            main_setting=self._meta.prefixed_name('FILTERS'),
-                            kind=kind))
-                data['FILTERS'][kind] = filters
-            elif kind not in data['FILTERS']:
-                # filters are not defined
-                data['FILTERS'][kind] = default_filters[kind]
-        return data


Test patch:
diff --git a/compressor/tests/test_conf.py b/compressor/tests/test_conf.py
--- a/compressor/tests/test_conf.py
+++ b/compressor/tests/test_conf.py
@@ -1,6 +1,5 @@
 from django.test import SimpleTestCase
 from django.test.utils import override_settings
-from django.core.exceptions import ImproperlyConfigured
 from compressor.conf import settings
 from compressor.conf import CompressorConf
 
@@ -30,47 +29,9 @@ def test_filter_defaults(self):
         # which contains no values for filers and therefore uses the defaults.
         self.assertEqual(settings.COMPRESS_FILTERS['css'], default_css_filters)
         self.assertEqual(settings.COMPRESS_FILTERS['js'], default_js_filters)
-        self.assertFalse(hasattr(settings, 'COMPRESS_CSS_FILTERS'))
-        self.assertFalse(hasattr(settings, 'COMPRESS_JS_FILTERS'))
 
-    @override_settings(COMPRESS_FILTERS=dict(),
-                       COMPRESS_CSS_FILTERS=None,
-                       COMPRESS_JS_FILTERS=None)
-    def test_filters_by_default(self):
-        conf = create_conf()
-        self.assertEqual(conf.FILTERS['css'], default_css_filters)
-        self.assertEqual(conf.FILTERS['js'], default_js_filters)
-        self.assertFalse(hasattr(conf, 'COMPRESS_CSS_FILTERS'))
-        self.assertFalse(hasattr(conf, 'COMPRESS_JS_FILTERS'))
-
-    @override_settings(COMPRESS_FILTERS=dict(),
-                       COMPRESS_CSS_FILTERS=['ham'],
-                       COMPRESS_JS_FILTERS=['spam'])
-    def test_filters_by_specific_settings(self):
-        conf = create_conf()
-        self.assertEqual(conf.FILTERS['css'], ['ham'])
-        self.assertEqual(conf.FILTERS['js'], ['spam'])
-        self.assertFalse(hasattr(conf, 'COMPRESS_CSS_FILTERS'))
-        self.assertFalse(hasattr(conf, 'COMPRESS_JS_FILTERS'))
-
-    @override_settings(COMPRESS_FILTERS=dict(css=['ham'], js=['spam']),
-                       COMPRESS_CSS_FILTERS=None,
-                       COMPRESS_JS_FILTERS=None)
+    @override_settings(COMPRESS_FILTERS=dict(css=['ham'], js=['spam']))
     def test_filters_by_main_setting(self):
         conf = create_conf()
         self.assertEqual(conf.FILTERS['css'], ['ham'])
         self.assertEqual(conf.FILTERS['js'], ['spam'])
-        self.assertFalse(hasattr(conf, 'COMPRESS_CSS_FILTERS'))
-        self.assertFalse(hasattr(conf, 'COMPRESS_JS_FILTERS'))
-
-    @override_settings(COMPRESS_FILTERS=dict(css=['ham']),
-                       COMPRESS_CSS_FILTERS=['spam'])
-    def test_css_filters_conflict(self):
-        with self.assertRaises(ImproperlyConfigured):
-            create_conf()
-
-    @override_settings(COMPRESS_FILTERS=dict(js=['ham']),
-                       COMPRESS_JS_FILTERS=['spam'])
-    def test_js_filters_conflict(self):
-        with self.assertRaises(ImproperlyConfigured):
-            create_conf()