mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-30 08:04:24 +08:00
Re-organize directory structure (#4971)
See discussion in #2491 Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
This commit is contained in:
0
stdlib/urllib/__init__.pyi
Normal file
0
stdlib/urllib/__init__.pyi
Normal file
13
stdlib/urllib/error.pyi
Normal file
13
stdlib/urllib/error.pyi
Normal file
@@ -0,0 +1,13 @@
|
||||
from typing import IO, Mapping, Optional, Union
|
||||
from urllib.response import addinfourl
|
||||
|
||||
# Stubs for urllib.error
|
||||
|
||||
class URLError(IOError):
|
||||
reason: Union[str, BaseException]
|
||||
|
||||
class HTTPError(URLError, addinfourl):
|
||||
code: int
|
||||
def __init__(self, url: str, code: int, msg: str, hdrs: Mapping[str, str], fp: Optional[IO[bytes]]) -> None: ...
|
||||
|
||||
class ContentTooShortError(URLError): ...
|
||||
152
stdlib/urllib/parse.pyi
Normal file
152
stdlib/urllib/parse.pyi
Normal file
@@ -0,0 +1,152 @@
|
||||
import sys
|
||||
from typing import Any, AnyStr, Callable, Dict, Generic, List, Mapping, NamedTuple, Optional, Sequence, Tuple, Union, overload
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_Str = Union[bytes, str]
|
||||
|
||||
uses_relative: List[str]
|
||||
uses_netloc: List[str]
|
||||
uses_params: List[str]
|
||||
non_hierarchical: List[str]
|
||||
uses_query: List[str]
|
||||
uses_fragment: List[str]
|
||||
scheme_chars: str
|
||||
MAX_CACHE_SIZE: int
|
||||
|
||||
class _ResultMixinBase(Generic[AnyStr]):
|
||||
def geturl(self) -> AnyStr: ...
|
||||
|
||||
class _ResultMixinStr(_ResultMixinBase[str]):
|
||||
def encode(self, encoding: str = ..., errors: str = ...) -> _ResultMixinBytes: ...
|
||||
|
||||
class _ResultMixinBytes(_ResultMixinBase[str]):
|
||||
def decode(self, encoding: str = ..., errors: str = ...) -> _ResultMixinStr: ...
|
||||
|
||||
class _NetlocResultMixinBase(Generic[AnyStr]):
|
||||
username: Optional[AnyStr]
|
||||
password: Optional[AnyStr]
|
||||
hostname: Optional[AnyStr]
|
||||
port: Optional[int]
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ...
|
||||
class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ...
|
||||
|
||||
class _DefragResultBase(Tuple[Any, ...], Generic[AnyStr]):
|
||||
url: AnyStr
|
||||
fragment: AnyStr
|
||||
|
||||
class _SplitResultBase(NamedTuple):
|
||||
scheme: str
|
||||
netloc: str
|
||||
path: str
|
||||
query: str
|
||||
fragment: str
|
||||
|
||||
class _SplitResultBytesBase(NamedTuple):
|
||||
scheme: bytes
|
||||
netloc: bytes
|
||||
path: bytes
|
||||
query: bytes
|
||||
fragment: bytes
|
||||
|
||||
class _ParseResultBase(NamedTuple):
|
||||
scheme: str
|
||||
netloc: str
|
||||
path: str
|
||||
params: str
|
||||
query: str
|
||||
fragment: str
|
||||
|
||||
class _ParseResultBytesBase(NamedTuple):
|
||||
scheme: bytes
|
||||
netloc: bytes
|
||||
path: bytes
|
||||
params: bytes
|
||||
query: bytes
|
||||
fragment: bytes
|
||||
|
||||
# Structured result objects for string data
|
||||
class DefragResult(_DefragResultBase[str], _ResultMixinStr): ...
|
||||
class SplitResult(_SplitResultBase, _NetlocResultMixinStr): ...
|
||||
class ParseResult(_ParseResultBase, _NetlocResultMixinStr): ...
|
||||
|
||||
# Structured result objects for bytes data
|
||||
class DefragResultBytes(_DefragResultBase[bytes], _ResultMixinBytes): ...
|
||||
class SplitResultBytes(_SplitResultBytesBase, _NetlocResultMixinBytes): ...
|
||||
class ParseResultBytes(_ParseResultBytesBase, _NetlocResultMixinBytes): ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def parse_qs(
|
||||
qs: Optional[AnyStr],
|
||||
keep_blank_values: bool = ...,
|
||||
strict_parsing: bool = ...,
|
||||
encoding: str = ...,
|
||||
errors: str = ...,
|
||||
max_num_fields: Optional[int] = ...,
|
||||
) -> Dict[AnyStr, List[AnyStr]]: ...
|
||||
def parse_qsl(
|
||||
qs: Optional[AnyStr],
|
||||
keep_blank_values: bool = ...,
|
||||
strict_parsing: bool = ...,
|
||||
encoding: str = ...,
|
||||
errors: str = ...,
|
||||
max_num_fields: Optional[int] = ...,
|
||||
) -> List[Tuple[AnyStr, AnyStr]]: ...
|
||||
|
||||
else:
|
||||
def parse_qs(
|
||||
qs: Optional[AnyStr], keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...
|
||||
) -> Dict[AnyStr, List[AnyStr]]: ...
|
||||
def parse_qsl(
|
||||
qs: Optional[AnyStr], keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...
|
||||
) -> List[Tuple[AnyStr, AnyStr]]: ...
|
||||
|
||||
@overload
|
||||
def quote(string: str, safe: _Str = ..., encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ...
|
||||
@overload
|
||||
def quote(string: bytes, safe: _Str = ...) -> str: ...
|
||||
def quote_from_bytes(bs: bytes, safe: _Str = ...) -> str: ...
|
||||
@overload
|
||||
def quote_plus(string: str, safe: _Str = ..., encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ...
|
||||
@overload
|
||||
def quote_plus(string: bytes, safe: _Str = ...) -> str: ...
|
||||
def unquote(string: str, encoding: str = ..., errors: str = ...) -> str: ...
|
||||
def unquote_to_bytes(string: _Str) -> bytes: ...
|
||||
def unquote_plus(string: str, encoding: str = ..., errors: str = ...) -> str: ...
|
||||
@overload
|
||||
def urldefrag(url: str) -> DefragResult: ...
|
||||
@overload
|
||||
def urldefrag(url: Optional[bytes]) -> DefragResultBytes: ...
|
||||
def urlencode(
|
||||
query: Union[Mapping[Any, Any], Mapping[Any, Sequence[Any]], Sequence[Tuple[Any, Any]], Sequence[Tuple[Any, Sequence[Any]]]],
|
||||
doseq: bool = ...,
|
||||
safe: AnyStr = ...,
|
||||
encoding: str = ...,
|
||||
errors: str = ...,
|
||||
quote_via: Callable[[str, AnyStr, str, str], str] = ...,
|
||||
) -> str: ...
|
||||
def urljoin(base: AnyStr, url: Optional[AnyStr], allow_fragments: bool = ...) -> AnyStr: ...
|
||||
@overload
|
||||
def urlparse(url: str, scheme: Optional[str] = ..., allow_fragments: bool = ...) -> ParseResult: ...
|
||||
@overload
|
||||
def urlparse(url: Optional[bytes], scheme: Optional[bytes] = ..., allow_fragments: bool = ...) -> ParseResultBytes: ...
|
||||
@overload
|
||||
def urlsplit(url: str, scheme: Optional[str] = ..., allow_fragments: bool = ...) -> SplitResult: ...
|
||||
@overload
|
||||
def urlsplit(url: Optional[bytes], scheme: Optional[bytes] = ..., allow_fragments: bool = ...) -> SplitResultBytes: ...
|
||||
@overload
|
||||
def urlunparse(
|
||||
components: Tuple[Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr]]
|
||||
) -> AnyStr: ...
|
||||
@overload
|
||||
def urlunparse(components: Sequence[Optional[AnyStr]]) -> AnyStr: ...
|
||||
@overload
|
||||
def urlunsplit(
|
||||
components: Tuple[Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr]]
|
||||
) -> AnyStr: ...
|
||||
@overload
|
||||
def urlunsplit(components: Sequence[Optional[AnyStr]]) -> AnyStr: ...
|
||||
343
stdlib/urllib/request.pyi
Normal file
343
stdlib/urllib/request.pyi
Normal file
@@ -0,0 +1,343 @@
|
||||
import os
|
||||
import ssl
|
||||
from email.message import Message
|
||||
from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol
|
||||
from http.cookiejar import CookieJar
|
||||
from typing import (
|
||||
IO,
|
||||
Any,
|
||||
Callable,
|
||||
ClassVar,
|
||||
Dict,
|
||||
List,
|
||||
Mapping,
|
||||
NoReturn,
|
||||
Optional,
|
||||
Pattern,
|
||||
Sequence,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
from urllib.error import HTTPError
|
||||
from urllib.response import addinfourl
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_UrlopenRet = Any
|
||||
|
||||
def urlopen(
|
||||
url: Union[str, Request],
|
||||
data: Optional[bytes] = ...,
|
||||
timeout: Optional[float] = ...,
|
||||
*,
|
||||
cafile: Optional[str] = ...,
|
||||
capath: Optional[str] = ...,
|
||||
cadefault: bool = ...,
|
||||
context: Optional[ssl.SSLContext] = ...,
|
||||
) -> _UrlopenRet: ...
|
||||
def install_opener(opener: OpenerDirector) -> None: ...
|
||||
def build_opener(*handlers: Union[BaseHandler, Callable[[], BaseHandler]]) -> OpenerDirector: ...
|
||||
def url2pathname(pathname: str) -> str: ...
|
||||
def pathname2url(pathname: str) -> str: ...
|
||||
def getproxies() -> Dict[str, str]: ...
|
||||
def parse_http_list(s: str) -> List[str]: ...
|
||||
def parse_keqv_list(l: List[str]) -> Dict[str, str]: ...
|
||||
def proxy_bypass(host: str) -> Any: ... # Undocumented
|
||||
|
||||
class Request:
|
||||
@property
|
||||
def full_url(self) -> str: ...
|
||||
@full_url.setter
|
||||
def full_url(self, value: str) -> None: ...
|
||||
@full_url.deleter
|
||||
def full_url(self) -> None: ...
|
||||
type: str
|
||||
host: str
|
||||
origin_req_host: str
|
||||
selector: str
|
||||
data: Optional[bytes]
|
||||
headers: Dict[str, str]
|
||||
unredirected_hdrs: Dict[str, str]
|
||||
unverifiable: bool
|
||||
method: Optional[str]
|
||||
timeout: Optional[float] # Undocumented, only set after __init__() by OpenerDirector.open()
|
||||
def __init__(
|
||||
self,
|
||||
url: str,
|
||||
data: Optional[bytes] = ...,
|
||||
headers: Dict[str, str] = ...,
|
||||
origin_req_host: Optional[str] = ...,
|
||||
unverifiable: bool = ...,
|
||||
method: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def get_method(self) -> str: ...
|
||||
def add_header(self, key: str, val: str) -> None: ...
|
||||
def add_unredirected_header(self, key: str, val: str) -> None: ...
|
||||
def has_header(self, header_name: str) -> bool: ...
|
||||
def remove_header(self, header_name: str) -> None: ...
|
||||
def get_full_url(self) -> str: ...
|
||||
def set_proxy(self, host: str, type: str) -> None: ...
|
||||
@overload
|
||||
def get_header(self, header_name: str) -> Optional[str]: ...
|
||||
@overload
|
||||
def get_header(self, header_name: str, default: _T) -> Union[str, _T]: ...
|
||||
def header_items(self) -> List[Tuple[str, str]]: ...
|
||||
def has_proxy(self) -> bool: ...
|
||||
|
||||
class OpenerDirector:
|
||||
addheaders: List[Tuple[str, str]]
|
||||
def add_handler(self, handler: BaseHandler) -> None: ...
|
||||
def open(self, fullurl: Union[str, Request], data: Optional[bytes] = ..., timeout: Optional[float] = ...) -> _UrlopenRet: ...
|
||||
def error(self, proto: str, *args: Any) -> _UrlopenRet: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
class BaseHandler:
|
||||
handler_order: ClassVar[int]
|
||||
parent: OpenerDirector
|
||||
def add_parent(self, parent: OpenerDirector) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def http_error_nnn(self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]) -> _UrlopenRet: ...
|
||||
|
||||
class HTTPDefaultErrorHandler(BaseHandler):
|
||||
def http_error_default(
|
||||
self, req: Request, fp: IO[bytes], code: int, msg: str, hdrs: Mapping[str, str]
|
||||
) -> HTTPError: ... # undocumented
|
||||
|
||||
class HTTPRedirectHandler(BaseHandler):
|
||||
max_redirections: ClassVar[int] # undocumented
|
||||
max_repeats: ClassVar[int] # undocumented
|
||||
inf_msg: ClassVar[str] # undocumented
|
||||
def redirect_request(
|
||||
self, req: Request, fp: IO[str], code: int, msg: str, headers: Mapping[str, str], newurl: str
|
||||
) -> Optional[Request]: ...
|
||||
def http_error_301(
|
||||
self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]
|
||||
) -> Optional[_UrlopenRet]: ...
|
||||
def http_error_302(
|
||||
self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]
|
||||
) -> Optional[_UrlopenRet]: ...
|
||||
def http_error_303(
|
||||
self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]
|
||||
) -> Optional[_UrlopenRet]: ...
|
||||
def http_error_307(
|
||||
self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]
|
||||
) -> Optional[_UrlopenRet]: ...
|
||||
|
||||
class HTTPCookieProcessor(BaseHandler):
|
||||
cookiejar: CookieJar
|
||||
def __init__(self, cookiejar: Optional[CookieJar] = ...) -> None: ...
|
||||
def http_request(self, request: Request) -> Request: ... # undocumented
|
||||
def http_response(self, request: Request, response: HTTPResponse) -> HTTPResponse: ... # undocumented
|
||||
def https_request(self, request: Request) -> Request: ... # undocumented
|
||||
def https_response(self, request: Request, response: HTTPResponse) -> HTTPResponse: ... # undocumented
|
||||
|
||||
class ProxyHandler(BaseHandler):
|
||||
def __init__(self, proxies: Optional[Dict[str, str]] = ...) -> None: ...
|
||||
def proxy_open(self, req: Request, proxy: str, type: str) -> Optional[_UrlopenRet]: ... # undocumented
|
||||
# TODO add a method for every (common) proxy protocol
|
||||
|
||||
class HTTPPasswordMgr:
|
||||
def add_password(self, realm: str, uri: Union[str, Sequence[str]], user: str, passwd: str) -> None: ...
|
||||
def find_user_password(self, realm: str, authuri: str) -> Tuple[Optional[str], Optional[str]]: ...
|
||||
def is_suburi(self, base: str, test: str) -> bool: ... # undocumented
|
||||
def reduce_uri(self, uri: str, default_port: bool = ...) -> str: ... # undocumented
|
||||
|
||||
class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr):
|
||||
def add_password(self, realm: Optional[str], uri: Union[str, Sequence[str]], user: str, passwd: str) -> None: ...
|
||||
def find_user_password(self, realm: Optional[str], authuri: str) -> Tuple[Optional[str], Optional[str]]: ...
|
||||
|
||||
class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm):
|
||||
def add_password(
|
||||
self, realm: Optional[str], uri: Union[str, Sequence[str]], user: str, passwd: str, is_authenticated: bool = ...
|
||||
) -> None: ...
|
||||
def update_authenticated(self, uri: Union[str, Sequence[str]], is_authenticated: bool = ...) -> None: ...
|
||||
def is_authenticated(self, authuri: str) -> bool: ...
|
||||
|
||||
class AbstractBasicAuthHandler:
|
||||
rx: ClassVar[Pattern[str]] # undocumented
|
||||
def __init__(self, password_mgr: Optional[HTTPPasswordMgr] = ...) -> None: ...
|
||||
def http_error_auth_reqed(self, authreq: str, host: str, req: Request, headers: Mapping[str, str]) -> None: ...
|
||||
def http_request(self, req: Request) -> Request: ... # undocumented
|
||||
def http_response(self, req: Request, response: HTTPResponse) -> HTTPResponse: ... # undocumented
|
||||
def https_request(self, req: Request) -> Request: ... # undocumented
|
||||
def https_response(self, req: Request, response: HTTPResponse) -> HTTPResponse: ... # undocumented
|
||||
def retry_http_basic_auth(self, host: str, req: Request, realm: str) -> Optional[_UrlopenRet]: ... # undocumented
|
||||
|
||||
class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
|
||||
auth_header: ClassVar[str] # undocumented
|
||||
def http_error_401(
|
||||
self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]
|
||||
) -> Optional[_UrlopenRet]: ...
|
||||
|
||||
class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
|
||||
auth_header: ClassVar[str]
|
||||
def http_error_407(
|
||||
self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]
|
||||
) -> Optional[_UrlopenRet]: ...
|
||||
|
||||
class AbstractDigestAuthHandler:
|
||||
def __init__(self, passwd: Optional[HTTPPasswordMgr] = ...) -> None: ...
|
||||
def reset_retry_count(self) -> None: ...
|
||||
def http_error_auth_reqed(self, auth_header: str, host: str, req: Request, headers: Mapping[str, str]) -> None: ...
|
||||
def retry_http_digest_auth(self, req: Request, auth: str) -> Optional[_UrlopenRet]: ...
|
||||
def get_cnonce(self, nonce: str) -> str: ...
|
||||
def get_authorization(self, req: Request, chal: Mapping[str, str]) -> str: ...
|
||||
def get_algorithm_impls(self, algorithm: str) -> Tuple[Callable[[str], str], Callable[[str, str], str]]: ...
|
||||
def get_entity_digest(self, data: Optional[bytes], chal: Mapping[str, str]) -> Optional[str]: ...
|
||||
|
||||
class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
|
||||
auth_header: ClassVar[str] # undocumented
|
||||
def http_error_401(
|
||||
self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]
|
||||
) -> Optional[_UrlopenRet]: ...
|
||||
|
||||
class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
|
||||
auth_header: ClassVar[str] # undocumented
|
||||
def http_error_407(
|
||||
self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]
|
||||
) -> Optional[_UrlopenRet]: ...
|
||||
|
||||
class AbstractHTTPHandler(BaseHandler): # undocumented
|
||||
def __init__(self, debuglevel: int = ...) -> None: ...
|
||||
def set_http_debuglevel(self, level: int) -> None: ...
|
||||
def do_request_(self, request: Request) -> Request: ...
|
||||
def do_open(self, http_class: _HTTPConnectionProtocol, req: Request, **http_conn_args: Any) -> HTTPResponse: ...
|
||||
|
||||
class HTTPHandler(AbstractHTTPHandler):
|
||||
def http_open(self, req: Request) -> HTTPResponse: ...
|
||||
def http_request(self, request: Request) -> Request: ... # undocumented
|
||||
|
||||
class HTTPSHandler(AbstractHTTPHandler):
|
||||
def __init__(
|
||||
self, debuglevel: int = ..., context: Optional[ssl.SSLContext] = ..., check_hostname: Optional[bool] = ...
|
||||
) -> None: ...
|
||||
def https_open(self, req: Request) -> HTTPResponse: ...
|
||||
def https_request(self, request: Request) -> Request: ... # undocumented
|
||||
|
||||
class FileHandler(BaseHandler):
|
||||
names: ClassVar[Optional[Tuple[str, ...]]] # undocumented
|
||||
def file_open(self, req: Request) -> addinfourl: ...
|
||||
def get_names(self) -> Tuple[str, ...]: ... # undocumented
|
||||
def open_local_file(self, req: Request) -> addinfourl: ... # undocumented
|
||||
|
||||
class DataHandler(BaseHandler):
|
||||
def data_open(self, req: Request) -> addinfourl: ...
|
||||
|
||||
class ftpwrapper: # undocumented
|
||||
def __init__(
|
||||
self, user: str, passwd: str, host: str, port: int, dirs: str, timeout: Optional[float] = ..., persistent: bool = ...
|
||||
) -> None: ...
|
||||
|
||||
class FTPHandler(BaseHandler):
|
||||
def ftp_open(self, req: Request) -> addinfourl: ...
|
||||
def connect_ftp(
|
||||
self, user: str, passwd: str, host: str, port: int, dirs: str, timeout: float
|
||||
) -> ftpwrapper: ... # undocumented
|
||||
|
||||
class CacheFTPHandler(FTPHandler):
|
||||
def setTimeout(self, t: float) -> None: ...
|
||||
def setMaxConns(self, m: int) -> None: ...
|
||||
def check_cache(self) -> None: ... # undocumented
|
||||
def clear_cache(self) -> None: ... # undocumented
|
||||
def connect_ftp(
|
||||
self, user: str, passwd: str, host: str, port: int, dirs: str, timeout: float
|
||||
) -> ftpwrapper: ... # undocumented
|
||||
|
||||
class UnknownHandler(BaseHandler):
|
||||
def unknown_open(self, req: Request) -> NoReturn: ...
|
||||
|
||||
class HTTPErrorProcessor(BaseHandler):
|
||||
def http_response(self, request: Request, response: HTTPResponse) -> _UrlopenRet: ...
|
||||
def https_response(self, request: Request, response: HTTPResponse) -> _UrlopenRet: ...
|
||||
|
||||
def urlretrieve(
|
||||
url: str,
|
||||
filename: Optional[Union[str, os.PathLike[Any]]] = ...,
|
||||
reporthook: Optional[Callable[[int, int, int], None]] = ...,
|
||||
data: Optional[bytes] = ...,
|
||||
) -> Tuple[str, HTTPMessage]: ...
|
||||
def urlcleanup() -> None: ...
|
||||
|
||||
class URLopener:
|
||||
version: ClassVar[str]
|
||||
def __init__(self, proxies: Optional[Dict[str, str]] = ..., **x509: str) -> None: ...
|
||||
def open(self, fullurl: str, data: Optional[bytes] = ...) -> _UrlopenRet: ...
|
||||
def open_unknown(self, fullurl: str, data: Optional[bytes] = ...) -> _UrlopenRet: ...
|
||||
def retrieve(
|
||||
self,
|
||||
url: str,
|
||||
filename: Optional[str] = ...,
|
||||
reporthook: Optional[Callable[[int, int, int], None]] = ...,
|
||||
data: Optional[bytes] = ...,
|
||||
) -> Tuple[str, Optional[Message]]: ...
|
||||
def addheader(self, *args: Tuple[str, str]) -> None: ... # undocumented
|
||||
def cleanup(self) -> None: ... # undocumented
|
||||
def close(self) -> None: ... # undocumented
|
||||
def http_error(
|
||||
self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ...
|
||||
) -> _UrlopenRet: ... # undocumented
|
||||
def http_error_default(
|
||||
self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: Mapping[str, str]
|
||||
) -> _UrlopenRet: ... # undocumented
|
||||
def open_data(self, url: str, data: Optional[bytes] = ...) -> addinfourl: ... # undocumented
|
||||
def open_file(self, url: str) -> addinfourl: ... # undocumented
|
||||
def open_ftp(self, url: str) -> addinfourl: ... # undocumented
|
||||
def open_http(self, url: str, data: Optional[bytes] = ...) -> _UrlopenRet: ... # undocumented
|
||||
def open_https(self, url: str, data: Optional[bytes] = ...) -> _UrlopenRet: ... # undocumented
|
||||
def open_local_file(self, url: str) -> addinfourl: ... # undocumented
|
||||
def open_unknown_proxy(self, proxy: str, fullurl: str, data: Optional[bytes] = ...) -> None: ... # undocumented
|
||||
|
||||
class FancyURLopener(URLopener):
|
||||
def prompt_user_passwd(self, host: str, realm: str) -> Tuple[str, str]: ...
|
||||
def get_user_passwd(self, host: str, realm: str, clear_cache: int = ...) -> Tuple[str, str]: ... # undocumented
|
||||
def http_error_301(
|
||||
self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ...
|
||||
) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented
|
||||
def http_error_302(
|
||||
self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ...
|
||||
) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented
|
||||
def http_error_303(
|
||||
self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ...
|
||||
) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented
|
||||
def http_error_307(
|
||||
self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ...
|
||||
) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented
|
||||
def http_error_401(
|
||||
self,
|
||||
url: str,
|
||||
fp: IO[str],
|
||||
errcode: int,
|
||||
errmsg: str,
|
||||
headers: Mapping[str, str],
|
||||
data: Optional[bytes] = ...,
|
||||
retry: bool = ...,
|
||||
) -> Optional[_UrlopenRet]: ... # undocumented
|
||||
def http_error_407(
|
||||
self,
|
||||
url: str,
|
||||
fp: IO[str],
|
||||
errcode: int,
|
||||
errmsg: str,
|
||||
headers: Mapping[str, str],
|
||||
data: Optional[bytes] = ...,
|
||||
retry: bool = ...,
|
||||
) -> Optional[_UrlopenRet]: ... # undocumented
|
||||
def http_error_default(
|
||||
self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: Mapping[str, str]
|
||||
) -> addinfourl: ... # undocumented
|
||||
def redirect_internal(
|
||||
self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes]
|
||||
) -> Optional[_UrlopenRet]: ... # undocumented
|
||||
def retry_http_basic_auth(
|
||||
self, url: str, realm: str, data: Optional[bytes] = ...
|
||||
) -> Optional[_UrlopenRet]: ... # undocumented
|
||||
def retry_https_basic_auth(
|
||||
self, url: str, realm: str, data: Optional[bytes] = ...
|
||||
) -> Optional[_UrlopenRet]: ... # undocumented
|
||||
def retry_proxy_http_basic_auth(
|
||||
self, url: str, realm: str, data: Optional[bytes] = ...
|
||||
) -> Optional[_UrlopenRet]: ... # undocumented
|
||||
def retry_proxy_https_basic_auth(
|
||||
self, url: str, realm: str, data: Optional[bytes] = ...
|
||||
) -> Optional[_UrlopenRet]: ... # undocumented
|
||||
51
stdlib/urllib/response.pyi
Normal file
51
stdlib/urllib/response.pyi
Normal file
@@ -0,0 +1,51 @@
|
||||
from email.message import Message
|
||||
from types import TracebackType
|
||||
from typing import IO, Any, BinaryIO, Callable, Iterable, List, Optional, Tuple, Type, TypeVar
|
||||
|
||||
_AIUT = TypeVar("_AIUT", bound=addbase)
|
||||
|
||||
class addbase(BinaryIO):
|
||||
fp: IO[bytes]
|
||||
def __init__(self, fp: IO[bytes]) -> None: ...
|
||||
def __enter__(self: _AIUT) -> _AIUT: ...
|
||||
def __exit__(
|
||||
self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
def __iter__(self: _AIUT) -> _AIUT: ...
|
||||
def __next__(self) -> bytes: ...
|
||||
def close(self) -> None: ...
|
||||
# These methods don't actually exist, but the class inherits at runtime from
|
||||
# tempfile._TemporaryFileWrapper, which uses __getattr__ to delegate to the
|
||||
# underlying file object. To satisfy the BinaryIO interface, we pretend that this
|
||||
# class has these additional methods.
|
||||
def fileno(self) -> int: ...
|
||||
def flush(self) -> None: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def read(self, n: int = ...) -> bytes: ...
|
||||
def readable(self) -> bool: ...
|
||||
def readline(self, limit: int = ...) -> bytes: ...
|
||||
def readlines(self, hint: int = ...) -> List[bytes]: ...
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, size: Optional[int] = ...) -> int: ...
|
||||
def writable(self) -> bool: ...
|
||||
def write(self, s: bytes) -> int: ...
|
||||
def writelines(self, lines: Iterable[bytes]) -> None: ...
|
||||
|
||||
class addclosehook(addbase):
|
||||
closehook: Callable[..., object]
|
||||
hookargs: Tuple[Any, ...]
|
||||
def __init__(self, fp: IO[bytes], closehook: Callable[..., object], *hookargs: Any) -> None: ...
|
||||
|
||||
class addinfo(addbase):
|
||||
headers: Message
|
||||
def __init__(self, fp: IO[bytes], headers: Message) -> None: ...
|
||||
def info(self) -> Message: ...
|
||||
|
||||
class addinfourl(addinfo):
|
||||
url: str
|
||||
code: int
|
||||
def __init__(self, fp: IO[bytes], headers: Message, url: str, code: Optional[int] = ...) -> None: ...
|
||||
def geturl(self) -> str: ...
|
||||
def getcode(self) -> int: ...
|
||||
19
stdlib/urllib/robotparser.pyi
Normal file
19
stdlib/urllib/robotparser.pyi
Normal file
@@ -0,0 +1,19 @@
|
||||
import sys
|
||||
from typing import Iterable, List, NamedTuple, Optional
|
||||
|
||||
class _RequestRate(NamedTuple):
|
||||
requests: int
|
||||
seconds: int
|
||||
|
||||
class RobotFileParser:
|
||||
def __init__(self, url: str = ...) -> None: ...
|
||||
def set_url(self, url: str) -> None: ...
|
||||
def read(self) -> None: ...
|
||||
def parse(self, lines: Iterable[str]) -> None: ...
|
||||
def can_fetch(self, user_agent: str, url: str) -> bool: ...
|
||||
def mtime(self) -> int: ...
|
||||
def modified(self) -> None: ...
|
||||
def crawl_delay(self, useragent: str) -> Optional[str]: ...
|
||||
def request_rate(self, useragent: str) -> Optional[_RequestRate]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def site_maps(self) -> Optional[List[str]]: ...
|
||||
Reference in New Issue
Block a user