From 0cf7a2a89688ef7910f6962e81f8323dfe6cf422 Mon Sep 17 00:00:00 2001 From: Alexander Maryanovsky Date: Mon, 12 Apr 2021 19:37:02 +0300 Subject: [PATCH] Type-hint stream_request_body so that the type of stream_request_body(cls) is the same as the type of cls. --- tornado/web.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: -- 2.47.2