mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Improve werkzeug stubs (#2391)
This commit is contained in:
committed by
Jelle Zijlstra
parent
d45fc3daaf
commit
a2676ec972
15
third_party/2and3/werkzeug/contrib/fixers.pyi
vendored
15
third_party/2and3/werkzeug/contrib/fixers.pyi
vendored
@@ -1,4 +1,5 @@
|
||||
from typing import Any
|
||||
from typing import Any, Sequence, Optional, Iterable
|
||||
from wsgiref.types import WSGIApplication, WSGIEnvironment, StartResponse
|
||||
|
||||
class CGIRootFix:
|
||||
app = ... # type: Any
|
||||
@@ -13,12 +14,12 @@ class PathInfoFromRequestUriFix:
|
||||
def __init__(self, app): ...
|
||||
def __call__(self, environ, start_response): ...
|
||||
|
||||
class ProxyFix:
|
||||
app = ... # type: Any
|
||||
num_proxies = ... # type: Any
|
||||
def __init__(self, app, num_proxies=1): ...
|
||||
def get_remote_addr(self, forwarded_for): ...
|
||||
def __call__(self, environ, start_response): ...
|
||||
class ProxyFix(object):
|
||||
app: WSGIApplication
|
||||
num_proxies: int
|
||||
def __init__(self, app: WSGIApplication, num_proxies: int = ...) -> None: ...
|
||||
def get_remote_addr(self, forwarded_for: Sequence[str]) -> Optional[str]: ...
|
||||
def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ...
|
||||
|
||||
class HeaderRewriterFix:
|
||||
app = ... # type: Any
|
||||
|
||||
43
third_party/2and3/werkzeug/datastructures.pyi
vendored
43
third_party/2and3/werkzeug/datastructures.pyi
vendored
@@ -1,7 +1,12 @@
|
||||
import collections
|
||||
from typing import Any, Optional, Mapping, Dict
|
||||
from typing import Any, Optional, Mapping, Dict, TypeVar, Callable, Union, overload
|
||||
from collections import Container, Iterable, MutableSet
|
||||
|
||||
_K = TypeVar("_K")
|
||||
_V = TypeVar("_V")
|
||||
_R = TypeVar("_R")
|
||||
_D = TypeVar("_D")
|
||||
|
||||
def is_immutable(self): ...
|
||||
def iter_multi_items(mapping): ...
|
||||
def native_itermethods(names): ...
|
||||
@@ -56,12 +61,19 @@ class UpdateDictMixin:
|
||||
popitem = ... # type: Any
|
||||
update = ... # type: Any
|
||||
|
||||
class TypeConversionDict(dict):
|
||||
def get(self, key, default=None, type=None): ...
|
||||
class TypeConversionDict(Dict[_K, _V]):
|
||||
@overload
|
||||
def get(self, key: _K, *, type: None = ...) -> Optional[_V]: ...
|
||||
@overload
|
||||
def get(self, key: _K, default: _D, type: None = ...) -> Union[_V, _D]: ...
|
||||
@overload
|
||||
def get(self, key: _K, *, type: Callable[[_V], _R]) -> Optional[_R]: ...
|
||||
@overload
|
||||
def get(self, key: _K, default: _D, type: Callable[[_V], _R]) -> Union[_R, _D]: ...
|
||||
|
||||
class ImmutableTypeConversionDict(ImmutableDictMixin, TypeConversionDict):
|
||||
def copy(self): ...
|
||||
def __copy__(self): ...
|
||||
class ImmutableTypeConversionDict(ImmutableDictMixin, TypeConversionDict[_K, _V]):
|
||||
def copy(self) -> TypeConversionDict[_K, _V]: ...
|
||||
def __copy__(self) -> ImmutableTypeConversionDict[_K, _V]: ...
|
||||
|
||||
class ViewItems:
|
||||
def __init__(self, multi_dict, method, repr_name, *a, **kw): ...
|
||||
@@ -130,7 +142,24 @@ class Headers(collections.Mapping):
|
||||
def __getitem__(self, key, _get_mode=False): ...
|
||||
def __eq__(self, other): ...
|
||||
def __ne__(self, other): ...
|
||||
def get(self, key, default=None, type=None, as_bytes=False): ...
|
||||
@overload
|
||||
def get(self, key: str, *, type: None = ...) -> Optional[str]: ...
|
||||
@overload
|
||||
def get(self, key: str, default: _D, type: None = ...) -> Union[str, _D]: ...
|
||||
@overload
|
||||
def get(self, key: str, *, type: Callable[[str], _R]) -> Optional[_R]: ...
|
||||
@overload
|
||||
def get(self, key: str, default: _D, type: Callable[[str], _R]) -> Union[_R, _D]: ...
|
||||
@overload
|
||||
def get(self, key: str, *, as_bytes: bool) -> Any: ...
|
||||
@overload
|
||||
def get(self, key: str, *, type: None, as_bytes: bool) -> Any: ...
|
||||
@overload
|
||||
def get(self, key: str, *, type: Callable[[Any], _R], as_bytes: bool) -> Optional[_R]: ...
|
||||
@overload
|
||||
def get(self, key: str, default: Any, type: None, as_bytes: bool) -> Any: ...
|
||||
@overload
|
||||
def get(self, key: str, default: _D, type: Callable[[Any], _R], as_bytes: bool) -> Union[_R, _D]: ...
|
||||
def getlist(self, key, type=None, as_bytes=False): ...
|
||||
def get_all(self, name): ...
|
||||
def items(self, lower=False): ...
|
||||
|
||||
5
third_party/2and3/werkzeug/wrappers.pyi
vendored
5
third_party/2and3/werkzeug/wrappers.pyi
vendored
@@ -7,7 +7,7 @@ from wsgiref.types import WSGIEnvironment, InputStream
|
||||
|
||||
from .datastructures import (
|
||||
Authorization, CombinedMultiDict, EnvironHeaders, Headers, ImmutableMultiDict,
|
||||
MultiDict, TypeConversionDict, HeaderSet,
|
||||
MultiDict, ImmutableTypeConversionDict, HeaderSet,
|
||||
Accept, MIMEAccept, CharsetAccept, LanguageAccept,
|
||||
)
|
||||
|
||||
@@ -47,7 +47,8 @@ class BaseRequest:
|
||||
form = ... # type: ImmutableMultiDict
|
||||
values = ... # type: CombinedMultiDict
|
||||
files = ... # type: MultiDict
|
||||
cookies = ... # type: TypeConversionDict
|
||||
@property
|
||||
def cookies(self) -> ImmutableTypeConversionDict[str, str]: ...
|
||||
headers = ... # type: EnvironHeaders
|
||||
path = ... # type: Text
|
||||
full_path = ... # type: Text
|
||||
|
||||
Reference in New Issue
Block a user