Skip to content

Commit

Permalink
Deprecate SlimItFilter, stop testing it with Python 3.7+ (#1102)
Browse files Browse the repository at this point in the history
* Deprecate SlimItFilter, stop testing it with Python 3.7+
  • Loading branch information
diox committed Feb 23, 2022
1 parent 6a6bae8 commit be78248
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
17 changes: 13 additions & 4 deletions compressor/filters/jsmin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

from django.core.exceptions import ImproperlyConfigured

from compressor.filters import FilterBase, CallbackOutputFilter
Expand All @@ -6,9 +8,7 @@
class rJSMinFilter(CallbackOutputFilter):
callback = "rjsmin.jsmin"
dependencies = ["rjsmin"]
kwargs = {
"keep_bang_comments": True
}
kwargs = {"keep_bang_comments": True}


# This is for backwards compatibility
Expand All @@ -22,6 +22,14 @@ class SlimItFilter(CallbackOutputFilter):
"mangle": True,
}

def __init__(self, *args, **kwargs):
warnings.warn(
"SlimItFilter is broken in Python 3.6+ and will be removed in "
"django-compressor 3.3.",
DeprecationWarning,
)
super().__init__(*args, **kwargs)


class CalmjsFilter(FilterBase):
def __init__(self, *args, **kwargs):
Expand All @@ -39,7 +47,8 @@ def __init__(self, *args, **kwargs):
except ImportError:
raise ImproperlyConfigured(
"The module calmjs.parse couldn't be imported. "
"Make sure it is correctly installed.")
"Make sure it is correctly installed."
)
if self._parser is None:
self._parser = calmjs.parse.es5
if self._unparser is None:
Expand Down
3 changes: 2 additions & 1 deletion compressor/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import sys
from collections import defaultdict
from unittest import mock
from unittest import mock, skipIf

from django.conf import settings
from django.test import override_settings, TestCase
Expand Down Expand Up @@ -202,6 +202,7 @@ def test_jsmin_filter(self):
self.assertEqual(output, rJSMinFilter(content).output())


@skipIf(sys.version_info >= (3, 7), reason="Unsupported in Python 3.7+")
class SlimItTestCase(TestCase):
def test_slimit_filter(self):
content = """
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

v3.2 (unreleased)
-----------------

`Full Changelog <https://github.com/django-compressor/django-compressor/compare/3.1...3.2>`_

- Deprecate SlimItFilter, stop testing it with Python 3.7 or higher


v3.1 (2021-12-18)
-----------------

Expand Down
7 changes: 0 additions & 7 deletions docs/quickstart.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ Optional Dependencies

pip install html5lib

- `Slim It`_

For the :ref:`Slim It filter <slimit_filter>`
``compressor.filters.jsmin.SlimItFilter``::

pip install slimit

- `Calmjs`_

For the :ref:`Calmjs filter <calmjs_filter>`
Expand Down
7 changes: 0 additions & 7 deletions docs/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,6 @@ Backend settings
A filter that uses the jsmin implementation rJSmin_ to compress
JavaScript code (installed by default).

.. _slimit_filter:

- ``compressor.filters.jsmin.SlimItFilter``

A filter that uses the jsmin implementation `Slim It`_ to compress
JavaScript code.

.. _calmjs_filter:

- ``compressor.filters.jsmin.CalmjsFilter``
Expand Down

0 comments on commit be78248

Please sign in to comment.