From 5f52080f507baddcb1113fa312616a63fa1fefa0 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 15 Nov 2017 00:05:31 +0100 Subject: [PATCH 1/2] Fix werkzeug environ type PEP 3333 explicitly calls for environ to be a built-in dict. Using a Mapping will not only prevent the dict from being modified (which is explicitly allowed by PEP 3333), it will also cause interaction problems when the environment is passed to other WSGI handlers. Also change the value type from object to Any for convenience. By definition, the values can be anything and can't be type checked. Using object instead of Any forces us to explicitly cast the value whenever we access it. --- third_party/2/werkzeug/wrappers.pyi | 6 +++--- third_party/3/werkzeug/wrappers.pyi | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/third_party/2/werkzeug/wrappers.pyi b/third_party/2/werkzeug/wrappers.pyi index 98b258241b28..2f3d03fd8d48 100644 --- a/third_party/2/werkzeug/wrappers.pyi +++ b/third_party/2/werkzeug/wrappers.pyi @@ -1,5 +1,5 @@ from typing import ( - Any, Iterable, Mapping, Optional, Sequence, Tuple, Type, Union, + Any, Iterable, Mapping, Optional, Sequence, Tuple, Type, Union, Dict, ) from .datastructures import ( @@ -18,9 +18,9 @@ class BaseRequest: form_data_parser_class = ... # type: Type trusted_hosts = ... # type: Optional[Sequence[unicode]] disable_data_descriptor = ... # type: Any - environ = ... # type: Mapping[str, object] + environ = ... # type: Dict[str, Any] shallow = ... # type: Any - def __init__(self, environ: Mapping[basestring, object], populate_request: bool = ..., shallow: bool = ...) -> None: ... + def __init__(self, environ: Dict[str, Any], populate_request: bool = ..., shallow: bool = ...) -> None: ... @property def url_charset(self) -> str: ... @classmethod diff --git a/third_party/3/werkzeug/wrappers.pyi b/third_party/3/werkzeug/wrappers.pyi index 676d1be4c1e9..08bf9d42ebe2 100644 --- a/third_party/3/werkzeug/wrappers.pyi +++ b/third_party/3/werkzeug/wrappers.pyi @@ -1,5 +1,5 @@ from typing import ( - Any, Iterable, Mapping, Optional, Sequence, Tuple, Type, Union, + Any, Iterable, Mapping, Optional, Sequence, Tuple, Type, Union, Dict, ) from .datastructures import ( @@ -18,9 +18,9 @@ class BaseRequest: form_data_parser_class = ... # type: Type trusted_hosts = ... # type: Optional[Sequence[str]] disable_data_descriptor = ... # type: Any - environ = ... # type: Mapping[str, object] + environ = ... # type: Dict[str, Any] shallow = ... # type: Any - def __init__(self, environ: Mapping[str, object], populate_request: bool = ..., shallow: bool = ...) -> None: ... + def __init__(self, environ: Dict[str, Any], populate_request: bool = ..., shallow: bool = ...) -> None: ... @property def url_charset(self) -> str: ... @classmethod From 2c622f0b055a56df8372986e0f2beed8276005e7 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 15 Nov 2017 00:20:51 +0100 Subject: [PATCH 2/2] Use Union[str, unicode] for Werkzeug environment keys This matches the type in wsgiref.types. --- third_party/2/werkzeug/wrappers.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/2/werkzeug/wrappers.pyi b/third_party/2/werkzeug/wrappers.pyi index 2f3d03fd8d48..d9bf4e3b2b0d 100644 --- a/third_party/2/werkzeug/wrappers.pyi +++ b/third_party/2/werkzeug/wrappers.pyi @@ -18,9 +18,9 @@ class BaseRequest: form_data_parser_class = ... # type: Type trusted_hosts = ... # type: Optional[Sequence[unicode]] disable_data_descriptor = ... # type: Any - environ = ... # type: Dict[str, Any] + environ = ... # type: Dict[Union[str, unicode], Any] shallow = ... # type: Any - def __init__(self, environ: Dict[str, Any], populate_request: bool = ..., shallow: bool = ...) -> None: ... + def __init__(self, environ: Dict[Union[str, unicode], Any], populate_request: bool = ..., shallow: bool = ...) -> None: ... @property def url_charset(self) -> str: ... @classmethod