diff --git a/pipeline/packager.py b/pipeline/packager.py index bd301890..c9ecf6f7 100644 --- a/pipeline/packager.py +++ b/pipeline/packager.py @@ -65,7 +65,7 @@ def manifest(self): def compiler_options(self): return self.config.get("compiler_options", {}) - @lru_cache() + @lru_cache def get_sri(self, path): method = self.config.get("integrity") if method not in {"sha256", "sha384", "sha512"}: @@ -75,7 +75,8 @@ def get_sri(self, path): h = getattr(hashlib, method)() for data in iter(lambda: fd.read(16384), b""): h.update(data) - return "%s-%s" % (method, base64.b64encode(h.digest()).decode()) + digest = base64.b64encode(h.digest()).decode() + return f"{method}-{digest}" return None diff --git a/tests/tests/test_template.py b/tests/tests/test_template.py index cc685b81..0fc05c02 100644 --- a/tests/tests/test_template.py +++ b/tests/tests/test_template.py @@ -121,7 +121,8 @@ def test_sri_sha512(self): def get_integrity(path, method): with staticfiles_storage.open(path) as fd: h = getattr(hashlib, method)(fd.read()) - return "%s-%s" % (method, base64.b64encode(h.digest()).decode()) + digest = base64.b64encode(h.digest()).decode() + return f"{method}-{digest}" class DjangoTest(TestCase):