diff --git a/django-stubs/middleware/cache.pyi b/django-stubs/middleware/cache.pyi index 6f1e2efce..b9f0756ee 100644 --- a/django-stubs/middleware/cache.pyi +++ b/django-stubs/middleware/cache.pyi @@ -1,32 +1,32 @@ -from collections.abc import Callable from typing import Any from django.core.cache import BaseCache from django.http.request import HttpRequest from django.http.response import HttpResponse, HttpResponseBase -from django.utils.deprecation import MiddlewareMixin +from django.utils.deprecation import MiddlewareMixin, _AsyncGetResponseCallable, _GetResponseCallable class UpdateCacheMiddleware(MiddlewareMixin): cache_timeout: float key_prefix: str cache_alias: str - cache: BaseCache + @property + def cache(self) -> BaseCache: ... def process_response(self, request: HttpRequest, response: HttpResponseBase | str) -> HttpResponseBase | str: ... class FetchFromCacheMiddleware(MiddlewareMixin): key_prefix: str cache_alias: str - cache: BaseCache + @property + def cache(self) -> BaseCache: ... def process_request(self, request: HttpRequest) -> HttpResponse | None: ... class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware): key_prefix: str cache_alias: str cache_timeout: float - cache: BaseCache def __init__( self, - get_response: Callable = ..., + get_response: _GetResponseCallable | _AsyncGetResponseCallable, cache_timeout: float | None = ..., page_timeout: float | None = ..., **kwargs: Any, diff --git a/django-stubs/middleware/gzip.pyi b/django-stubs/middleware/gzip.pyi index e25dca8be..e1c10a768 100644 --- a/django-stubs/middleware/gzip.pyi +++ b/django-stubs/middleware/gzip.pyi @@ -1,4 +1,4 @@ -from typing import Any +from typing import Any, ClassVar from django.http.request import HttpRequest from django.http.response import HttpResponseBase @@ -7,4 +7,5 @@ from django.utils.deprecation import MiddlewareMixin re_accepts_gzip: Any class GZipMiddleware(MiddlewareMixin): + max_random_bytes: ClassVar[int] def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ... diff --git a/scripts/stubtest/allowlist_todo.txt b/scripts/stubtest/allowlist_todo.txt index 68b70560e..f22355c00 100644 --- a/scripts/stubtest/allowlist_todo.txt +++ b/scripts/stubtest/allowlist_todo.txt @@ -1354,11 +1354,6 @@ django.http.request.HttpRequest.readlines django.http.request.UploadHandlerList django.http.request.parse_accept_header django.http.response.StreamingHttpResponse.content -django.middleware.cache.CacheMiddleware.__init__ -django.middleware.cache.CacheMiddleware.cache -django.middleware.cache.FetchFromCacheMiddleware.cache -django.middleware.cache.UpdateCacheMiddleware.cache -django.middleware.gzip.GZipMiddleware.max_random_bytes django.template.EngineHandler.__init__ django.template.Library.filter_function django.template.Library.simple_tag