Skip to content

Commit 63d1c0b

Browse files
committed
fix formatting
1 parent db96513 commit 63d1c0b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

wagtailcache/cache.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
from django.core.handlers.wsgi import WSGIRequest
1818
from django.http.response import HttpResponse
1919
from django.template.response import SimpleTemplateResponse
20-
from django.utils.cache import cc_delim_re, set_response_etag, \
21-
patch_cache_control
20+
from django.utils.cache import cc_delim_re
2221
from django.utils.cache import get_cache_key
2322
from django.utils.cache import get_max_age
2423
from django.utils.cache import has_vary_header
2524
from django.utils.cache import learn_cache_key
2625
from django.utils.cache import patch_cache_control
2726
from django.utils.cache import patch_response_headers
27+
from django.utils.cache import set_response_etag
2828
from django.utils.deprecation import MiddlewareMixin
2929
from django.utils.http import parse_etags
3030
from wagtail import hooks
@@ -223,7 +223,7 @@ def process_request(self, request: WSGIRequest) -> Optional[HttpResponse]:
223223
setattr(request, "_wagtailcache_update", True)
224224
return None
225225
# We have a key, get the cached response.
226-
response = self._wagcache.get(cache_key)
226+
response: HttpResponse = self._wagcache.get(cache_key)
227227

228228
except Exception:
229229
# If the cache backend is currently unresponsive or errors out,
@@ -235,13 +235,14 @@ def process_request(self, request: WSGIRequest) -> Optional[HttpResponse]:
235235
if response is None:
236236
setattr(request, "_wagtailcache_update", True)
237237
return None
238-
239238
# Hit. Return cached response or Not Modified.
240239
setattr(request, "_wagtailcache_update", False)
241-
response: HttpResponse
242-
if "If-None-Match" in request.headers and "Etag" in response.headers and \
243-
response.headers["Etag"] in parse_etags(
244-
request.headers["If-None-Match"]):
240+
if (
241+
"If-None-Match" in request.headers
242+
and "Etag" in response.headers
243+
and response.headers["Etag"]
244+
in parse_etags(request.headers["If-None-Match"])
245+
):
245246
not_modified = HttpResponse(status=304)
246247
not_modified.headers["Etag"] = response.headers["Etag"]
247248
# TODO: Cache-Control and Expires?

0 commit comments

Comments
 (0)