mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
* urlparse: allow unicode arguments in more places Part of #1411 urlunsplit() and similar functions accept either unicode or str in all places. Their actual return type is unicode if any of the arguments is unicode and nonempty, which the type system can't exactly express. I left the return type as str because str is implicitly promoted to unicode, so using the return type in a place that accepts unicode should work. unquote, parse_qs, and parse_qsl return unicode if you pass them unicode, so AnyStr is appropriate in their stubs. * fix type for urldefrag The return type was wrong; this function returns a 2-tuple. The second member of the tuple is always a `str` if the argument type does not contain '#', and otherwise matches the type of the argument.
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
# Stubs for urlparse (Python 2)
|
|
|
|
from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload
|
|
|
|
_String = Union[str, unicode]
|
|
|
|
uses_relative = ... # type: List[str]
|
|
uses_netloc = ... # type: List[str]
|
|
uses_params = ... # type: List[str]
|
|
non_hierarchical = ... # type: List[str]
|
|
uses_query = ... # type: List[str]
|
|
uses_fragment = ... # type: List[str]
|
|
scheme_chars = ... # type: str
|
|
MAX_CACHE_SIZE = 0
|
|
|
|
def clear_cache() -> None: ...
|
|
|
|
class ResultMixin(object):
|
|
@property
|
|
def username(self) -> str: ...
|
|
@property
|
|
def password(self) -> str: ...
|
|
@property
|
|
def hostname(self) -> str: ...
|
|
@property
|
|
def port(self) -> int: ...
|
|
|
|
class SplitResult(
|
|
NamedTuple(
|
|
'SplitResult',
|
|
[
|
|
('scheme', str), ('netloc', str), ('path', str), ('query', str), ('fragment', str)
|
|
]
|
|
),
|
|
ResultMixin
|
|
):
|
|
def geturl(self) -> str: ...
|
|
|
|
class ParseResult(
|
|
NamedTuple(
|
|
'ParseResult',
|
|
[
|
|
('scheme', str), ('netloc', str), ('path', str), ('params', str), ('query', str),
|
|
('fragment', str)
|
|
]
|
|
),
|
|
ResultMixin
|
|
):
|
|
def geturl(self) -> str: ...
|
|
|
|
def urlparse(url: _String, scheme: _String = ...,
|
|
allow_fragments: bool = ...) -> ParseResult: ...
|
|
def urlsplit(url: _String, scheme: _String = ...,
|
|
allow_fragments: bool = ...) -> SplitResult: ...
|
|
@overload
|
|
def urlunparse(data: Tuple[_String, _String, _String, _String, _String, _String]) -> str: ...
|
|
@overload
|
|
def urlunparse(data: Sequence[_String]) -> str: ...
|
|
@overload
|
|
def urlunsplit(data: Tuple[_String, _String, _String, _String, _String]) -> str: ...
|
|
@overload
|
|
def urlunsplit(data: Sequence[_String]) -> str: ...
|
|
def urljoin(base: _String, url: _String,
|
|
allow_fragments: bool = ...) -> str: ...
|
|
def urldefrag(url: AnyStr) -> Tuple[AnyStr, str]: ...
|
|
def unquote(s: AnyStr) -> AnyStr: ...
|
|
def parse_qs(qs: AnyStr, keep_blank_values: bool = ...,
|
|
strict_parsing: bool = ...) -> Dict[AnyStr, List[AnyStr]]: ...
|
|
def parse_qsl(qs: AnyStr, keep_blank_values: int = ...,
|
|
strict_parsing: bool = ...) -> List[Tuple[AnyStr, AnyStr]]: ...
|