middleware: Remove inappropriate StreamingHttpResponse annotation.

Asserting response.stream is False is just suggesting the response being
an `HttpResponse`. This removes `StreamingHttpResponse` with the more
generic `HttpResponseBase` with an isinstance-check.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-07-05 17:39:38 -04:00 committed by Tim Abbott
parent da4654d838
commit 7d86d291d4
1 changed files with 3 additions and 4 deletions

View File

@ -658,11 +658,10 @@ def alter_content(request: HttpRequest, content: bytes) -> bytes:
class FinalizeOpenGraphDescription(MiddlewareMixin): class FinalizeOpenGraphDescription(MiddlewareMixin):
def process_response( def process_response(
self, request: HttpRequest, response: StreamingHttpResponse self, request: HttpRequest, response: HttpResponseBase
) -> StreamingHttpResponse: ) -> HttpResponseBase:
if RequestNotes.get_notes(request).placeholder_open_graph_description is not None: if RequestNotes.get_notes(request).placeholder_open_graph_description is not None:
assert not response.streaming assert isinstance(response, HttpResponse)
response.content = alter_content(request, response.content) response.content = alter_content(request, response.content)
return response return response