diff --git a/third_party/2and3/werkzeug/exceptions.pyi b/third_party/2and3/werkzeug/exceptions.pyi index 9236e1541..5c92d0873 100644 --- a/third_party/2and3/werkzeug/exceptions.pyi +++ b/third_party/2and3/werkzeug/exceptions.pyi @@ -22,7 +22,7 @@ class HTTPException(Exception): def get_response(self, environ: Optional[Union[WSGIEnvironment, _EnvironContainer]] = ...) -> Response: ... def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ... -default_exceptions: Dict[int, HTTPException] +default_exceptions: Dict[int, Type[HTTPException]] class BadRequest(HTTPException): code = ... # type: int diff --git a/third_party/2and3/werkzeug/utils.pyi b/third_party/2and3/werkzeug/utils.pyi index 936af5e76..9d3ff78a6 100644 --- a/third_party/2and3/werkzeug/utils.pyi +++ b/third_party/2and3/werkzeug/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any, Optional, overload, Type, TypeVar from werkzeug._internal import _DictAccessorProperty from werkzeug.wrappers import Response @@ -31,7 +31,15 @@ def format_string(string, context): ... def secure_filename(filename): ... def escape(s, quote: Optional[Any] = ...): ... def unescape(s): ... -def redirect(location, code: int = ..., Response: Optional[Any] = ...) -> Response: ... + +# 'redirect' returns a werkzeug Response, unless you give it +# another Response type to use instead. +_RC = TypeVar("_RC", bound=Response) +@overload +def redirect(location, code: int = ..., Response: None = ...) -> Response: ... +@overload +def redirect(location, code: int = ..., Response: Type[_RC] = ...) -> _RC: ... + def append_slash_redirect(environ, code: int = ...): ... def import_string(import_name, silent: bool = ...): ... def find_modules(import_path, include_packages: bool = ..., recursive: bool = ...): ... diff --git a/third_party/2and3/werkzeug/wrappers.pyi b/third_party/2and3/werkzeug/wrappers.pyi index 9b81224d1..83705c366 100644 --- a/third_party/2and3/werkzeug/wrappers.pyi +++ b/third_party/2and3/werkzeug/wrappers.pyi @@ -43,7 +43,8 @@ class BaseRequest: args = ... # type: ImmutableMultiDict @property def data(self) -> bytes: ... - def get_data(self, cache: bool = ..., as_text: bool = ..., parse_form_data: bool = ...) -> bytes: ... + # TODO: once Literal types are supported, overload with as_text + def get_data(self, cache: bool = ..., as_text: bool = ..., parse_form_data: bool = ...) -> Any: ... # returns bytes if as_text is False (the default), else Text form = ... # type: ImmutableMultiDict values = ... # type: CombinedMultiDict files = ... # type: MultiDict @@ -105,6 +106,7 @@ class BaseResponse: def force_type(cls: Type[_SelfT], response: object, environ: Optional[WSGIEnvironment] = ...) -> _SelfT: ... @classmethod def from_app(cls: Type[_SelfT], app: Any, environ: WSGIEnvironment, buffered: bool = ...) -> _SelfT: ... + # TODO: once Literal types are supported, overload with as_text def get_data(self, as_text: bool = ...) -> Any: ... # returns bytes if as_text is False (the default), else Text def set_data(self, value: Union[bytes, Text]) -> None: ... data = ... # type: Any