From: Alexander Maryanovsky Date: Mon, 12 Apr 2021 16:37:02 +0000 (+0300) Subject: Type-hint stream_request_body so that the type of stream_request_body(cls) is the... X-Git-Tag: v6.2.0b1~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cf7a2a89688ef7910f6962e81f8323dfe6cf422;p=thirdparty%2Ftornado.git Type-hint stream_request_body so that the type of stream_request_body(cls) is the same as the type of cls. --- diff --git a/tornado/web.py b/tornado/web.py index ddf1de746..06e37c281 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -118,6 +118,7 @@ from typing import ( Iterable, Generator, Type, + TypeVar, cast, overload, ) @@ -1818,7 +1819,10 @@ class RequestHandler(object): self.clear_header(h) -def stream_request_body(cls: Type[RequestHandler]) -> Type[RequestHandler]: +RequestHandlerType = TypeVar("RequestHandlerType", bound=RequestHandler) + + +def stream_request_body(cls: Type[RequestHandlerType]) -> Type[RequestHandlerType]: """Apply to `RequestHandler` subclasses to enable streaming body support. This decorator implies the following changes: