1from typing import IO, Any, AnyStr, List, Mapping, Sequence, Text, Tuple, TypeVar, Union
2
3def url2pathname(pathname: AnyStr) -> AnyStr: ...
4def pathname2url(pathname: AnyStr) -> AnyStr: ...
5def urlopen(url: str, data=..., proxies: Mapping[str, str] = ..., context=...) -> IO[Any]: ...
6def urlretrieve(url, filename=..., reporthook=..., data=..., context=...): ...
7def urlcleanup() -> None: ...
8
9class ContentTooShortError(IOError):
10    content: Any
11    def __init__(self, message, content) -> None: ...
12
13class URLopener:
14    version: Any
15    proxies: Any
16    key_file: Any
17    cert_file: Any
18    context: Any
19    addheaders: Any
20    tempcache: Any
21    ftpcache: Any
22    def __init__(self, proxies: Mapping[str, str] = ..., context=..., **x509) -> None: ...
23    def __del__(self): ...
24    def close(self): ...
25    def cleanup(self): ...
26    def addheader(self, *args): ...
27    type: Any
28    def open(self, fullurl: str, data=...): ...
29    def open_unknown(self, fullurl, data=...): ...
30    def open_unknown_proxy(self, proxy, fullurl, data=...): ...
31    def retrieve(self, url, filename=..., reporthook=..., data=...): ...
32    def open_http(self, url, data=...): ...
33    def http_error(self, url, fp, errcode, errmsg, headers, data=...): ...
34    def http_error_default(self, url, fp, errcode, errmsg, headers): ...
35    def open_https(self, url, data=...): ...
36    def open_file(self, url): ...
37    def open_local_file(self, url): ...
38    def open_ftp(self, url): ...
39    def open_data(self, url, data=...): ...
40
41class FancyURLopener(URLopener):
42    auth_cache: Any
43    tries: Any
44    maxtries: Any
45    def __init__(self, *args, **kwargs) -> None: ...
46    def http_error_default(self, url, fp, errcode, errmsg, headers): ...
47    def http_error_302(self, url, fp, errcode, errmsg, headers, data=...): ...
48    def redirect_internal(self, url, fp, errcode, errmsg, headers, data): ...
49    def http_error_301(self, url, fp, errcode, errmsg, headers, data=...): ...
50    def http_error_303(self, url, fp, errcode, errmsg, headers, data=...): ...
51    def http_error_307(self, url, fp, errcode, errmsg, headers, data=...): ...
52    def http_error_401(self, url, fp, errcode, errmsg, headers, data=...): ...
53    def http_error_407(self, url, fp, errcode, errmsg, headers, data=...): ...
54    def retry_proxy_http_basic_auth(self, url, realm, data=...): ...
55    def retry_proxy_https_basic_auth(self, url, realm, data=...): ...
56    def retry_http_basic_auth(self, url, realm, data=...): ...
57    def retry_https_basic_auth(self, url, realm, data=...): ...
58    def get_user_passwd(self, host, realm, clear_cache=...): ...
59    def prompt_user_passwd(self, host, realm): ...
60
61class ftpwrapper:
62    user: Any
63    passwd: Any
64    host: Any
65    port: Any
66    dirs: Any
67    timeout: Any
68    refcount: Any
69    keepalive: Any
70    def __init__(self, user, passwd, host, port, dirs, timeout=..., persistent=...) -> None: ...
71    busy: Any
72    ftp: Any
73    def init(self): ...
74    def retrfile(self, file, type): ...
75    def endtransfer(self): ...
76    def close(self): ...
77    def file_close(self): ...
78    def real_close(self): ...
79
80_AIUT = TypeVar("_AIUT", bound=addbase)
81
82class addbase:
83    fp: Any
84    def read(self, n: int = ...) -> bytes: ...
85    def readline(self, limit: int = ...) -> bytes: ...
86    def readlines(self, hint: int = ...) -> List[bytes]: ...
87    def fileno(self) -> int: ...  # Optional[int], but that is rare
88    def __iter__(self: _AIUT) -> _AIUT: ...
89    def next(self) -> bytes: ...
90    def __init__(self, fp) -> None: ...
91    def close(self) -> None: ...
92
93class addclosehook(addbase):
94    closehook: Any
95    hookargs: Any
96    def __init__(self, fp, closehook, *hookargs) -> None: ...
97    def close(self): ...
98
99class addinfo(addbase):
100    headers: Any
101    def __init__(self, fp, headers) -> None: ...
102    def info(self): ...
103
104class addinfourl(addbase):
105    headers: Any
106    url: Any
107    code: Any
108    def __init__(self, fp, headers, url, code=...) -> None: ...
109    def info(self): ...
110    def getcode(self): ...
111    def geturl(self): ...
112
113def unwrap(url): ...
114def splittype(url): ...
115def splithost(url): ...
116def splituser(host): ...
117def splitpasswd(user): ...
118def splitport(host): ...
119def splitnport(host, defport=...): ...
120def splitquery(url): ...
121def splittag(url): ...
122def splitattr(url): ...
123def splitvalue(attr): ...
124def unquote(s: AnyStr) -> AnyStr: ...
125def unquote_plus(s: AnyStr) -> AnyStr: ...
126def quote(s: AnyStr, safe: Text = ...) -> AnyStr: ...
127def quote_plus(s: AnyStr, safe: Text = ...) -> AnyStr: ...
128def urlencode(query: Union[Sequence[Tuple[Any, Any]], Mapping[Any, Any]], doseq=...) -> str: ...
129def getproxies() -> Mapping[str, str]: ...
130def proxy_bypass(host: str) -> Any: ...  # Undocumented
131
132# Names in __all__ with no definition:
133#   basejoin
134