mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Add assorted werkzeug type hints (#3444)
* Annotate is_immutable() * Annotate ImmutableListMixin and make generic * Make ImmutableList generic and derive from generic List * Annotate Accept * Annotate MIMEAccept * Fix annotation of parse_accept_header()
This commit is contained in:
committed by
Jelle Zijlstra
parent
e4677d9ed4
commit
79d4e0dd08
94
third_party/2and3/werkzeug/datastructures.pyi
vendored
94
third_party/2and3/werkzeug/datastructures.pyi
vendored
@@ -1,34 +1,52 @@
|
||||
import collections
|
||||
from typing import Any, Optional, Mapping, Dict, TypeVar, Callable, Union, overload, Text, Protocol, Iterator, IO
|
||||
from collections import Container, Iterable, MutableSet
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Container,
|
||||
Dict,
|
||||
Generic,
|
||||
IO,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Mapping,
|
||||
MutableSet,
|
||||
NoReturn,
|
||||
Optional,
|
||||
Protocol,
|
||||
Text,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
|
||||
_K = TypeVar("_K")
|
||||
_V = TypeVar("_V")
|
||||
_R = TypeVar("_R")
|
||||
_D = TypeVar("_D")
|
||||
|
||||
def is_immutable(self): ...
|
||||
def is_immutable(self) -> NoReturn: ...
|
||||
def iter_multi_items(mapping): ...
|
||||
def native_itermethods(names): ...
|
||||
|
||||
class ImmutableListMixin(object):
|
||||
class ImmutableListMixin(object, Generic[_V]):
|
||||
def __hash__(self) -> int: ...
|
||||
def __reduce_ex__(self, protocol): ...
|
||||
def __delitem__(self, key): ...
|
||||
def __delslice__(self, i, j): ...
|
||||
def __iadd__(self, other): ...
|
||||
__imul__: Any
|
||||
def __setitem__(self, key, value): ...
|
||||
def __setslice__(self, i, j, value): ...
|
||||
def append(self, item): ...
|
||||
remove: Any
|
||||
def extend(self, iterable): ...
|
||||
def insert(self, pos, value): ...
|
||||
def pop(self, index: int = ...): ...
|
||||
def reverse(self): ...
|
||||
def sort(self, cmp: Optional[Any] = ..., key: Optional[Any] = ..., reverse: Optional[Any] = ...): ...
|
||||
def __reduce_ex__(self: _D, protocol) -> Tuple[Type[_D], List[_V]]: ...
|
||||
def __delitem__(self, key: _V) -> NoReturn: ...
|
||||
def __iadd__(self, other: Any) -> NoReturn: ...
|
||||
def __imul__(self, other: Any) -> NoReturn: ...
|
||||
def __setitem__(self, key: str, value: Any) -> NoReturn: ...
|
||||
def append(self, item: Any) -> NoReturn: ...
|
||||
def remove(self, item: Any) -> NoReturn: ...
|
||||
def extend(self, iterable: Any) -> NoReturn: ...
|
||||
def insert(self, pos: int, value: Any) -> NoReturn: ...
|
||||
def pop(self, index: int = ...) -> NoReturn: ...
|
||||
def reverse(self) -> NoReturn: ...
|
||||
def sort(self, cmp: Optional[Any] = ..., key: Optional[Any] = ..., reverse: Optional[Any] = ...) -> NoReturn: ...
|
||||
|
||||
class ImmutableList(ImmutableListMixin, list): ... # type: ignore
|
||||
class ImmutableList(ImmutableListMixin[_V], List[_V]): ... # type: ignore
|
||||
|
||||
class ImmutableDictMixin(object):
|
||||
@classmethod
|
||||
@@ -243,27 +261,35 @@ class ImmutableOrderedMultiDict(ImmutableMultiDictMixin, OrderedMultiDict[_K, _V
|
||||
def copy(self): ...
|
||||
def __copy__(self): ...
|
||||
|
||||
class Accept(ImmutableList):
|
||||
provided: Any
|
||||
def __init__(self, values=...): ...
|
||||
def __getitem__(self, key): ...
|
||||
def quality(self, key): ...
|
||||
def __contains__(self, value): ...
|
||||
def index(self, key): ...
|
||||
def find(self, key): ...
|
||||
def values(self): ...
|
||||
def to_header(self): ...
|
||||
def best_match(self, matches, default: Optional[Any] = ...): ...
|
||||
class Accept(ImmutableList[Tuple[str, float]]):
|
||||
provided: bool
|
||||
def __init__(self, values: Union[None, Accept, Iterable[Tuple[str, float]]] = ...) -> None: ...
|
||||
@overload
|
||||
def __getitem__(self, key: int) -> Tuple[str, float]: ...
|
||||
@overload
|
||||
def __getitem__(self, s: slice) -> List[Tuple[str, float]]: ...
|
||||
@overload
|
||||
def __getitem__(self, key: str) -> float: ...
|
||||
def quality(self, key: str) -> float: ...
|
||||
def __contains__(self, value: str) -> bool: ... # type: ignore
|
||||
def index(self, key: Union[str, Tuple[str, float]]) -> int: ... # type: ignore
|
||||
def find(self, key: Union[str, Tuple[str, float]]) -> int: ...
|
||||
def values(self) -> Iterator[str]: ...
|
||||
def to_header(self) -> str: ...
|
||||
@overload
|
||||
def best_match(self, matches: Iterable[str], default: None = ...) -> Optional[str]: ...
|
||||
@overload
|
||||
def best_match(self, matches: Iterable[str], default: _D) -> Union[str, _D]: ...
|
||||
@property
|
||||
def best(self): ...
|
||||
def best(self) -> Optional[str]: ...
|
||||
|
||||
class MIMEAccept(Accept):
|
||||
@property
|
||||
def accept_html(self): ...
|
||||
def accept_html(self) -> bool: ...
|
||||
@property
|
||||
def accept_xhtml(self): ...
|
||||
def accept_xhtml(self) -> bool: ...
|
||||
@property
|
||||
def accept_json(self): ...
|
||||
def accept_json(self) -> bool: ...
|
||||
|
||||
class LanguageAccept(Accept): ...
|
||||
class CharsetAccept(Accept): ...
|
||||
|
||||
2
third_party/2and3/werkzeug/http.pyi
vendored
2
third_party/2and3/werkzeug/http.pyi
vendored
@@ -46,7 +46,7 @@ def parse_options_header(value: _Str, multiple: bool = ...) -> Tuple[Any, ...]:
|
||||
@overload
|
||||
def parse_accept_header(value: Optional[Text]) -> Accept: ...
|
||||
@overload
|
||||
def parse_accept_header(value: Optional[_Str], cls: Callable[[Optional[_Str]], _T]) -> _T: ...
|
||||
def parse_accept_header(value: Optional[_Str], cls: Callable[[Optional[List[Tuple[str, float]]]], _T]) -> _T: ...
|
||||
@overload
|
||||
def parse_cache_control_header(value: Union[None, bytes, Text],
|
||||
on_update: Optional[Callable[[RequestCacheControl], Any]] = ...) -> RequestCacheControl: ...
|
||||
|
||||
Reference in New Issue
Block a user