|
| 1 | +# Stubs for urllib.parse |
| 2 | +from typing import Any, List, Dict, Tuple, AnyStr, Generic, Iterator, overload, Sequence, Mapping, Union, NamedTuple, Callable, Optional |
| 3 | +import sys |
| 4 | + |
| 5 | +_Str = Union[bytes, str] |
| 6 | + |
| 7 | + |
| 8 | +uses_relative: List[str] |
| 9 | +uses_netloc: List[str] |
| 10 | +uses_params: List[str] |
| 11 | +non_hierarchical: List[str] |
| 12 | +uses_query: List[str] |
| 13 | +uses_fragment: List[str] |
| 14 | +scheme_chars: str |
| 15 | +MAX_CACHE_SIZE = 0 |
| 16 | + |
| 17 | +class _ResultMixinBase(Generic[AnyStr]): |
| 18 | + def geturl(self) -> AnyStr: ... |
| 19 | + |
| 20 | +class _ResultMixinStr(_ResultMixinBase[str]): |
| 21 | + def encode(self, encoding: str = ..., errors: str = ...) -> _ResultMixinBytes: ... |
| 22 | + |
| 23 | + |
| 24 | +class _ResultMixinBytes(_ResultMixinBase[str]): |
| 25 | + def decode(self, encoding: str = ..., errors: str = ...) -> _ResultMixinStr: ... |
| 26 | + |
| 27 | + |
| 28 | +class _NetlocResultMixinBase(Generic[AnyStr]): |
| 29 | + username: AnyStr |
| 30 | + password: AnyStr |
| 31 | + hostname: AnyStr |
| 32 | + port: int |
| 33 | + |
| 34 | +class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ... |
| 35 | + |
| 36 | +class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ... |
| 37 | + |
| 38 | +class _DefragResultBase(Generic[AnyStr]): |
| 39 | + url: AnyStr |
| 40 | + fragment: AnyStr |
| 41 | + @overload |
| 42 | + def __getitem__(self, x: slice) -> AnyStr: ... |
| 43 | + @overload |
| 44 | + def __getitem__(self, x: int) -> AnyStr: ... |
| 45 | + def __iter__(self) -> Iterator[AnyStr]: ... |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +_SplitResultBase = NamedTuple( |
| 50 | + '_SplitResultBase', |
| 51 | + [ |
| 52 | + ('scheme', str), ('netloc', str), ('path', str), ('query', str), ('fragment', str) |
| 53 | + ] |
| 54 | +) |
| 55 | +_SplitResultBytesBase = NamedTuple( |
| 56 | + '_SplitResultBytesBase', |
| 57 | + [ |
| 58 | + ('scheme', bytes), ('netloc', bytes), ('path', bytes), ('query', bytes), ('fragment', bytes) |
| 59 | + ] |
| 60 | +) |
| 61 | + |
| 62 | +_ParseResultBase = NamedTuple( |
| 63 | + '_ParseResultBase', |
| 64 | + [ |
| 65 | + ('scheme', str), ('netloc', str), ('path', str), ('params', str), ('query', str), ('fragment', str) |
| 66 | + ] |
| 67 | +) |
| 68 | +_ParseResultBytesBase = NamedTuple( |
| 69 | + '_ParseResultBytesBase', |
| 70 | + [ |
| 71 | + ('scheme', bytes), ('netloc', bytes), ('path', bytes), ('params', bytes), ('query', bytes), ('fragment', bytes) |
| 72 | + ] |
| 73 | +) |
| 74 | + |
| 75 | +# Structured result objects for string data |
| 76 | +class DefragResult(_DefragResultBase[str], _ResultMixinStr): ... |
| 77 | + |
| 78 | +class SplitResult(_SplitResultBase, _NetlocResultMixinStr): ... |
| 79 | + |
| 80 | +class ParseResult(_ParseResultBase, _NetlocResultMixinStr): ... |
| 81 | + |
| 82 | +# Structured result objects for bytes data |
| 83 | +class DefragResultBytes(_DefragResultBase[bytes], _ResultMixinBytes): ... |
| 84 | + |
| 85 | +class SplitResultBytes(_SplitResultBytesBase, _NetlocResultMixinBytes): ... |
| 86 | + |
| 87 | +class ParseResultBytes(_ParseResultBytesBase, _NetlocResultMixinBytes): ... |
| 88 | + |
| 89 | + |
| 90 | +def parse_qs(qs: AnyStr, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> Dict[AnyStr, List[AnyStr]]: ... |
| 91 | + |
| 92 | +def parse_qsl(qs: AnyStr, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> List[Tuple[AnyStr, AnyStr]]: ... |
| 93 | + |
| 94 | + |
| 95 | +@overload |
| 96 | +def quote(string: str, safe: _Str = ..., encoding: str = ..., errors: str = ...) -> str: ... |
| 97 | +@overload |
| 98 | +def quote(string: bytes, safe: _Str = ...) -> str: ... |
| 99 | + |
| 100 | +def quote_from_bytes(bs: bytes, safe: _Str = ...) -> str: ... |
| 101 | + |
| 102 | +@overload |
| 103 | +def quote_plus(string: str, safe: _Str = ..., encoding: str = ..., errors: str = ...) -> str: ... |
| 104 | +@overload |
| 105 | +def quote_plus(string: bytes, safe: _Str = ...) -> str: ... |
| 106 | + |
| 107 | +def unquote(string: str, encoding: str = ..., errors: str = ...) -> str: ... |
| 108 | + |
| 109 | +def unquote_to_bytes(string: _Str) -> bytes: ... |
| 110 | + |
| 111 | +def unquote_plus(string: str, encoding: str = ..., errors: str = ...) -> str: ... |
| 112 | + |
| 113 | +@overload |
| 114 | +def urldefrag(url: str) -> DefragResult: ... |
| 115 | +@overload |
| 116 | +def urldefrag(url: bytes) -> DefragResultBytes: ... |
| 117 | + |
| 118 | +if sys.version_info >= (3, 5): |
| 119 | + def urlencode(query: Union[Mapping[Any, Any], |
| 120 | + Mapping[Any, Sequence[Any]], |
| 121 | + Sequence[Tuple[Any, Any]], |
| 122 | + Sequence[Tuple[Any, Sequence[Any]]]], |
| 123 | + doseq: bool = ..., safe: AnyStr = ..., encoding: str = ..., errors: str = ..., |
| 124 | + quote_via: Callable[[str, AnyStr, str, str], str] = ...) -> str: ... |
| 125 | +else: |
| 126 | + def urlencode(query: Union[Mapping[Any, Any], |
| 127 | + Mapping[Any, Sequence[Any]], |
| 128 | + Sequence[Tuple[Any, Any]], |
| 129 | + Sequence[Tuple[Any, Sequence[Any]]]], |
| 130 | + doseq: bool = ..., safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ... |
| 131 | + |
| 132 | +def urljoin(base: Optional[AnyStr], url: Optional[AnyStr], allow_fragments: bool = ...) -> AnyStr: ... |
| 133 | + |
| 134 | +@overload |
| 135 | +def urlparse(url: str, scheme: str = ..., allow_fragments: bool = ...) -> ParseResult: ... |
| 136 | +@overload |
| 137 | +def urlparse(url: bytes, scheme: bytes = ..., allow_fragments: bool = ...) -> ParseResultBytes: ... |
| 138 | + |
| 139 | +@overload |
| 140 | +def urlsplit(url: Optional[str], scheme: str = ..., allow_fragments: bool = ...) -> SplitResult: ... |
| 141 | +@overload |
| 142 | +def urlsplit(url: bytes, scheme: bytes = ..., allow_fragments: bool = ...) -> SplitResultBytes: ... |
| 143 | + |
| 144 | +@overload |
| 145 | +def urlunparse(components: Tuple[AnyStr, AnyStr, AnyStr, AnyStr, AnyStr, AnyStr]) -> AnyStr: ... |
| 146 | +@overload |
| 147 | +def urlunparse(components: Sequence[AnyStr]) -> AnyStr: ... |
| 148 | + |
| 149 | +@overload |
| 150 | +def urlunsplit(components: Tuple[AnyStr, AnyStr, AnyStr, AnyStr, AnyStr]) -> AnyStr: ... |
| 151 | +@overload |
| 152 | +def urlunsplit(components: Sequence[AnyStr]) -> AnyStr: ... |
0 commit comments