Skip to content

Commit 29563c3

Browse files
authored
Add urllib3 stubs (#6858)
1 parent 1fbc919 commit 29563c3

25 files changed

+673
-0
lines changed

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"stubs/SQLAlchemy",
6464
"stubs/stripe",
6565
"stubs/ttkthemes",
66+
"stubs/urllib3",
6667
"stubs/vobject"
6768
],
6869
"typeCheckingMode": "basic",
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
urllib3.HTTPConnectionPool.__init__
2+
urllib3.HTTPConnectionPool.urlopen
3+
urllib3.HTTPResponse.__init__
4+
urllib3.HTTPSConnectionPool.__init__
5+
urllib3.NullHandler
6+
urllib3.PoolManager.connection_from_host
7+
urllib3.PoolManager.connection_from_url
8+
urllib3.PoolManager.urlopen
9+
urllib3.ProxyManager.__init__
10+
urllib3.ProxyManager.connection_from_host
11+
urllib3.ProxyManager.urlopen
12+
urllib3.Retry.is_forced_retry
13+
urllib3.Retry.sleep
14+
urllib3._collections.HTTPHeaderDict.from_httplib
15+
urllib3._collections.HTTPHeaderDict.getlist
16+
urllib3._collections.RLock
17+
urllib3.connection.HTTPConnection.request
18+
urllib3.connection.HTTPSConnection.__init__
19+
urllib3.connection.VerifiedHTTPSConnection.__init__
20+
urllib3.connection.VerifiedHTTPSConnection.set_cert
21+
urllib3.connectionpool.ConnectionError
22+
urllib3.connectionpool.HTTPConnection.request
23+
urllib3.connectionpool.HTTPConnectionPool.__init__
24+
urllib3.connectionpool.HTTPConnectionPool.urlopen
25+
urllib3.connectionpool.HTTPResponse.__init__
26+
urllib3.connectionpool.HTTPSConnection.__init__
27+
urllib3.connectionpool.HTTPSConnectionPool.__init__
28+
urllib3.connectionpool.ProxyError.__init__
29+
urllib3.connectionpool.RequestMethods.request_encode_url
30+
urllib3.connectionpool.Retry.is_forced_retry
31+
urllib3.connectionpool.Retry.sleep
32+
urllib3.connectionpool.VerifiedHTTPSConnection.__init__
33+
urllib3.connectionpool.VerifiedHTTPSConnection.set_cert
34+
urllib3.exceptions.ProxyError.__init__
35+
urllib3.fields.RequestField.__init__
36+
urllib3.fields.RequestField.from_tuples
37+
urllib3.filepost.RequestField.__init__
38+
urllib3.filepost.RequestField.from_tuples
39+
urllib3.packages.ssl_match_hostname
40+
urllib3.packages.ssl_match_hostname._implementation
41+
urllib3.poolmanager.PoolManager.connection_from_host
42+
urllib3.poolmanager.PoolManager.connection_from_url
43+
urllib3.poolmanager.PoolManager.urlopen
44+
urllib3.poolmanager.ProxyManager.__init__
45+
urllib3.poolmanager.ProxyManager.connection_from_host
46+
urllib3.poolmanager.ProxyManager.urlopen
47+
urllib3.request.RequestMethods.request_encode_url
48+
urllib3.response.HTTPHeaderDict.from_httplib
49+
urllib3.response.HTTPHeaderDict.getlist
50+
urllib3.response.HTTPResponse.__init__
51+
urllib3.response.PY3
52+
urllib3.util.Retry.is_forced_retry
53+
urllib3.util.Retry.sleep
54+
urllib3.util.connection.poll
55+
urllib3.util.connection.select
56+
urllib3.util.retry.Retry.is_forced_retry
57+
urllib3.util.retry.Retry.sleep
58+
urllib3.util.ssl_.create_default_context
59+
urllib3.util.ssl_.ssl_wrap_socket

stubs/urllib3/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = "1.26.*"

stubs/urllib3/urllib3/__init__.pyi

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import logging
2+
from typing import Any
3+
4+
from . import connectionpool, filepost, poolmanager, response
5+
from .util import request as _request, retry, timeout, url
6+
7+
__license__: Any
8+
9+
HTTPConnectionPool = connectionpool.HTTPConnectionPool
10+
HTTPSConnectionPool = connectionpool.HTTPSConnectionPool
11+
connection_from_url = connectionpool.connection_from_url
12+
encode_multipart_formdata = filepost.encode_multipart_formdata
13+
PoolManager = poolmanager.PoolManager
14+
ProxyManager = poolmanager.ProxyManager
15+
proxy_from_url = poolmanager.proxy_from_url
16+
HTTPResponse = response.HTTPResponse
17+
make_headers = _request.make_headers
18+
get_host = url.get_host
19+
Timeout = timeout.Timeout
20+
Retry = retry.Retry
21+
22+
class NullHandler(logging.Handler):
23+
def emit(self, record): ...
24+
25+
def add_stderr_logger(level=...): ...
26+
def disable_warnings(category=...): ...
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from typing import Any, MutableMapping, NoReturn, TypeVar
2+
3+
_KT = TypeVar("_KT")
4+
_VT = TypeVar("_VT")
5+
6+
class RLock:
7+
def __enter__(self): ...
8+
def __exit__(self, exc_type, exc_value, traceback): ...
9+
10+
class RecentlyUsedContainer(MutableMapping[_KT, _VT]):
11+
ContainerCls: Any
12+
dispose_func: Any
13+
lock: Any
14+
def __init__(self, maxsize=..., dispose_func=...) -> None: ...
15+
def __getitem__(self, key): ...
16+
def __setitem__(self, key, value): ...
17+
def __delitem__(self, key): ...
18+
def __len__(self): ...
19+
def __iter__(self): ...
20+
def clear(self): ...
21+
def keys(self): ...
22+
23+
class HTTPHeaderDict(MutableMapping[str, str]):
24+
def __init__(self, headers=..., **kwargs) -> None: ...
25+
def __setitem__(self, key, val): ...
26+
def __getitem__(self, key): ...
27+
def __delitem__(self, key): ...
28+
def __contains__(self, key): ...
29+
def __eq__(self, other): ...
30+
def __iter__(self) -> NoReturn: ...
31+
def __len__(self) -> int: ...
32+
def __ne__(self, other): ...
33+
values: Any
34+
get: Any
35+
update: Any
36+
iterkeys: Any
37+
itervalues: Any
38+
def pop(self, key, default=...): ...
39+
def discard(self, key): ...
40+
def add(self, key, val): ...
41+
def extend(self, *args, **kwargs): ...
42+
def getlist(self, key): ...
43+
getheaders: Any
44+
getallmatchingheaders: Any
45+
iget: Any
46+
def copy(self): ...
47+
def iteritems(self): ...
48+
def itermerged(self): ...
49+
def items(self): ...
50+
@classmethod
51+
def from_httplib(cls, message, duplicates=...): ...

stubs/urllib3/urllib3/connection.pyi

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import ssl
2+
import sys
3+
from typing import Any
4+
5+
from . import exceptions, util
6+
from .packages import ssl_match_hostname
7+
from .util import ssl_
8+
9+
if sys.version_info >= (3, 0):
10+
from builtins import ConnectionError as ConnectionError
11+
from http.client import HTTPConnection as _HTTPConnection, HTTPException as HTTPException
12+
else:
13+
from httplib import HTTPConnection as _HTTPConnection, HTTPException as HTTPException
14+
class ConnectionError(Exception): ...
15+
16+
class DummyConnection: ...
17+
18+
BaseSSLError = ssl.SSLError
19+
20+
ConnectTimeoutError = exceptions.ConnectTimeoutError
21+
SystemTimeWarning = exceptions.SystemTimeWarning
22+
SecurityWarning = exceptions.SecurityWarning
23+
match_hostname = ssl_match_hostname.match_hostname
24+
resolve_cert_reqs = ssl_.resolve_cert_reqs
25+
resolve_ssl_version = ssl_.resolve_ssl_version
26+
ssl_wrap_socket = ssl_.ssl_wrap_socket
27+
assert_fingerprint = ssl_.assert_fingerprint
28+
connection = util.connection
29+
30+
port_by_scheme: Any
31+
RECENT_DATE: Any
32+
33+
class HTTPConnection(_HTTPConnection):
34+
default_port: Any
35+
default_socket_options: Any
36+
is_verified: Any
37+
source_address: Any
38+
socket_options: Any
39+
def __init__(self, *args, **kw) -> None: ...
40+
def connect(self): ...
41+
42+
class HTTPSConnection(HTTPConnection):
43+
default_port: Any
44+
key_file: Any
45+
cert_file: Any
46+
def __init__(self, host, port=..., key_file=..., cert_file=..., strict=..., timeout=..., **kw) -> None: ...
47+
sock: Any
48+
def connect(self): ...
49+
50+
class VerifiedHTTPSConnection(HTTPSConnection):
51+
cert_reqs: Any
52+
ca_certs: Any
53+
ssl_version: Any
54+
assert_fingerprint: Any
55+
key_file: Any
56+
cert_file: Any
57+
assert_hostname: Any
58+
def set_cert(self, key_file=..., cert_file=..., cert_reqs=..., ca_certs=..., assert_hostname=..., assert_fingerprint=...): ...
59+
sock: Any
60+
auto_open: Any
61+
is_verified: Any
62+
def connect(self): ...
63+
64+
UnverifiedHTTPSConnection = HTTPSConnection
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
from typing import Any
2+
3+
from . import connection, exceptions, request, response
4+
from .connection import BaseSSLError as BaseSSLError, ConnectionError as ConnectionError, HTTPException as HTTPException
5+
from .packages import ssl_match_hostname
6+
from .util import connection as _connection, retry, timeout, url
7+
8+
ClosedPoolError = exceptions.ClosedPoolError
9+
ProtocolError = exceptions.ProtocolError
10+
EmptyPoolError = exceptions.EmptyPoolError
11+
HostChangedError = exceptions.HostChangedError
12+
LocationValueError = exceptions.LocationValueError
13+
MaxRetryError = exceptions.MaxRetryError
14+
ProxyError = exceptions.ProxyError
15+
ReadTimeoutError = exceptions.ReadTimeoutError
16+
SSLError = exceptions.SSLError
17+
TimeoutError = exceptions.TimeoutError
18+
InsecureRequestWarning = exceptions.InsecureRequestWarning
19+
CertificateError = ssl_match_hostname.CertificateError
20+
port_by_scheme = connection.port_by_scheme
21+
DummyConnection = connection.DummyConnection
22+
HTTPConnection = connection.HTTPConnection
23+
HTTPSConnection = connection.HTTPSConnection
24+
VerifiedHTTPSConnection = connection.VerifiedHTTPSConnection
25+
RequestMethods = request.RequestMethods
26+
HTTPResponse = response.HTTPResponse
27+
is_connection_dropped = _connection.is_connection_dropped
28+
Retry = retry.Retry
29+
Timeout = timeout.Timeout
30+
get_host = url.get_host
31+
32+
xrange: Any
33+
log: Any
34+
35+
class ConnectionPool:
36+
scheme: Any
37+
QueueCls: Any
38+
host: Any
39+
port: Any
40+
def __init__(self, host, port=...) -> None: ...
41+
def __enter__(self): ...
42+
def __exit__(self, exc_type, exc_val, exc_tb): ...
43+
def close(self): ...
44+
45+
class HTTPConnectionPool(ConnectionPool, RequestMethods):
46+
scheme: Any
47+
ConnectionCls: Any
48+
strict: Any
49+
timeout: Any
50+
retries: Any
51+
pool: Any
52+
block: Any
53+
proxy: Any
54+
proxy_headers: Any
55+
num_connections: Any
56+
num_requests: Any
57+
conn_kw: Any
58+
def __init__(
59+
self,
60+
host,
61+
port=...,
62+
strict=...,
63+
timeout=...,
64+
maxsize=...,
65+
block=...,
66+
headers=...,
67+
retries=...,
68+
_proxy=...,
69+
_proxy_headers=...,
70+
**conn_kw,
71+
) -> None: ...
72+
def close(self): ...
73+
def is_same_host(self, url): ...
74+
def urlopen(
75+
self,
76+
method,
77+
url,
78+
body=...,
79+
headers=...,
80+
retries=...,
81+
redirect=...,
82+
assert_same_host=...,
83+
timeout=...,
84+
pool_timeout=...,
85+
release_conn=...,
86+
**response_kw,
87+
): ...
88+
89+
class HTTPSConnectionPool(HTTPConnectionPool):
90+
scheme: Any
91+
ConnectionCls: Any
92+
key_file: Any
93+
cert_file: Any
94+
cert_reqs: Any
95+
ca_certs: Any
96+
ssl_version: Any
97+
assert_hostname: Any
98+
assert_fingerprint: Any
99+
def __init__(
100+
self,
101+
host,
102+
port=...,
103+
strict=...,
104+
timeout=...,
105+
maxsize=...,
106+
block=...,
107+
headers=...,
108+
retries=...,
109+
_proxy=...,
110+
_proxy_headers=...,
111+
key_file=...,
112+
cert_file=...,
113+
cert_reqs=...,
114+
ca_certs=...,
115+
ssl_version=...,
116+
assert_hostname=...,
117+
assert_fingerprint=...,
118+
**conn_kw,
119+
) -> None: ...
120+
121+
def connection_from_url(url, **kw): ...

stubs/urllib3/urllib3/contrib/__init__.pyi

Whitespace-only changes.

stubs/urllib3/urllib3/exceptions.pyi

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from typing import Any
2+
3+
class HTTPError(Exception): ...
4+
class HTTPWarning(Warning): ...
5+
6+
class PoolError(HTTPError):
7+
pool: Any
8+
def __init__(self, pool, message) -> None: ...
9+
def __reduce__(self): ...
10+
11+
class RequestError(PoolError):
12+
url: Any
13+
def __init__(self, pool, url, message) -> None: ...
14+
def __reduce__(self): ...
15+
16+
class SSLError(HTTPError): ...
17+
class ProxyError(HTTPError): ...
18+
class DecodeError(HTTPError): ...
19+
class ProtocolError(HTTPError): ...
20+
21+
ConnectionError: Any
22+
23+
class MaxRetryError(RequestError):
24+
reason: Any
25+
def __init__(self, pool, url, reason=...) -> None: ...
26+
27+
class HostChangedError(RequestError):
28+
retries: Any
29+
def __init__(self, pool, url, retries=...) -> None: ...
30+
31+
class TimeoutStateError(HTTPError): ...
32+
class TimeoutError(HTTPError): ...
33+
class ReadTimeoutError(TimeoutError, RequestError): ...
34+
class ConnectTimeoutError(TimeoutError): ...
35+
class EmptyPoolError(PoolError): ...
36+
class ClosedPoolError(PoolError): ...
37+
class LocationValueError(ValueError, HTTPError): ...
38+
39+
class LocationParseError(LocationValueError):
40+
location: Any
41+
def __init__(self, location) -> None: ...
42+
43+
class ResponseError(HTTPError):
44+
GENERIC_ERROR: Any
45+
SPECIFIC_ERROR: Any
46+
47+
class SecurityWarning(HTTPWarning): ...
48+
class InsecureRequestWarning(SecurityWarning): ...
49+
class SystemTimeWarning(SecurityWarning): ...
50+
class InsecurePlatformWarning(SecurityWarning): ...

0 commit comments

Comments
 (0)