mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Fix werkzeug environ type (#1831)
* 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. * Use Union[str, unicode] for Werkzeug environment keys This matches the type in wsgiref.types. * Use WSGIEnvironment from wsgiref.types * Add '= ...' to environ attribute
This commit is contained in:
committed by
Jelle Zijlstra
parent
66e5863ead
commit
a08d57833f
6
third_party/2/werkzeug/wrappers.pyi
vendored
6
third_party/2/werkzeug/wrappers.pyi
vendored
@@ -2,6 +2,8 @@ from typing import (
|
||||
Any, Iterable, Mapping, Optional, Sequence, Tuple, Type, Union,
|
||||
)
|
||||
|
||||
from wsgiref.types import WSGIEnvironment
|
||||
|
||||
from .datastructures import (
|
||||
CombinedMultiDict, EnvironHeaders, Headers, ImmutableMultiDict,
|
||||
MultiDict, TypeConversionDict,
|
||||
@@ -18,9 +20,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: WSGIEnvironment = ...
|
||||
shallow = ... # type: Any
|
||||
def __init__(self, environ: Mapping[basestring, object], populate_request: bool = ..., shallow: bool = ...) -> None: ...
|
||||
def __init__(self, environ: WSGIEnvironment, populate_request: bool = ..., shallow: bool = ...) -> None: ...
|
||||
@property
|
||||
def url_charset(self) -> str: ...
|
||||
@classmethod
|
||||
|
||||
6
third_party/3/werkzeug/wrappers.pyi
vendored
6
third_party/3/werkzeug/wrappers.pyi
vendored
@@ -2,6 +2,8 @@ from typing import (
|
||||
Any, Iterable, Mapping, Optional, Sequence, Tuple, Type, Union,
|
||||
)
|
||||
|
||||
from wsgiref.types import WSGIEnvironment
|
||||
|
||||
from .datastructures import (
|
||||
CombinedMultiDict, EnvironHeaders, Headers, ImmutableMultiDict,
|
||||
MultiDict, TypeConversionDict,
|
||||
@@ -18,9 +20,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: WSGIEnvironment = ...
|
||||
shallow = ... # type: Any
|
||||
def __init__(self, environ: Mapping[str, object], populate_request: bool = ..., shallow: bool = ...) -> None: ...
|
||||
def __init__(self, environ: WSGIEnvironment, populate_request: bool = ..., shallow: bool = ...) -> None: ...
|
||||
@property
|
||||
def url_charset(self) -> str: ...
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user