From 893ad6bb029ef54a4d4800cc81d8ab76185df819 Mon Sep 17 00:00:00 2001 From: jonfoster Date: Thu, 3 Jun 2021 19:25:25 +0100 Subject: [PATCH] #629: Add HTTP response "streaming" attribute (#632) Add the missing attribute django.http.response.StreamingHttpResponse.streaming . This is actually done by moving the attribute from HttpResponse to the base class HttpResponseBase. The real Django source code declares this attribute on HttpResponse and StreamingHttpResponse, however that's only because Django doesn't have type hints. The right place for the type hint is on the base class HttpResponseBase, since all instances of that base class are actually instances of HttpResponse or StreamingHttpResponse or a subclass of those two classes. So it's guaranteed that every HttpResponseBase instance has the attribute. Fixes bug #629. --- django-stubs/http/response.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django-stubs/http/response.pyi b/django-stubs/http/response.pyi index 2bc42d2..bb6c2a5 100644 --- a/django-stubs/http/response.pyi +++ b/django-stubs/http/response.pyi @@ -23,6 +23,7 @@ class ResponseHeaders(CaseInsensitiveMapping): class HttpResponseBase(Iterable[Any]): status_code: int = ... + streaming: bool = ... cookies: SimpleCookie = ... reason_phrase: str = ... charset: str = ... @@ -81,7 +82,6 @@ class HttpResponse(HttpResponseBase): test_server_port: str test_was_secure_request: bool xframe_options_exempt: bool - streaming: bool = ... def __init__(self, content: object = ..., *args: Any, **kwargs: Any) -> None: ... def serialize(self) -> bytes: ... __bytes__ = serialize