Use super() from Python 3
MODIFY
dummyserver/server.py
dummyserver/server.py
@@ -102,7 +102,7 @@ class SocketServerThread(threading.Thread):
USE_IPV6 = HAS_IPV6_AND_DNS
def __init__(self, socket_handler, host="localhost", port=8081, ready_event=None):
- threading.Thread.__init__(self)
+ super().__init__()
self.daemon = True
self.socket_handler = socket_handler

MODIFY
src/urllib3/connection.py
src/urllib3/connection.py
@@ -102,7 +102,7 @@ class HTTPConnection(_HTTPConnection):
self.proxy = kw.pop("proxy", None)
self.proxy_config = kw.pop("proxy_config", None)
- _HTTPConnection.__init__(self, *args, **kw)
+ super().__init__(*args, **kw)
@property
def host(self):
@@ -186,12 +186,12 @@ class HTTPConnection(_HTTPConnection):
f"Method cannot contain non-token characters {method!r} (found at least {match.group()!r})"
)
- return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)
+ return super().putrequest(method, url, *args, **kwargs)
def putheader(self, header, *values):
""""""
if SKIP_HEADER not in values:
- _HTTPConnection.putheader(self, header, *values)
+ super().putheader(header, *values)
elif six.ensure_str(header.lower()) not in SKIPPABLE_HEADERS:
raise ValueError(
"urllib3.util.SKIP_HEADER only supports '{}'".format(
@@ -277,7 +277,7 @@ class HTTPSConnection(HTTPConnection):
**kw,
):
- HTTPConnection.__init__(self, host, port, timeout=timeout, **kw)
+ super().__init__(host, port, timeout=timeout, **kw)
self.key_file = key_file
self.cert_file = cert_file

MODIFY
src/urllib3/connectionpool.py
src/urllib3/connectionpool.py
@@ -856,8 +856,7 @@ class HTTPSConnectionPool(HTTPConnectionPool):
**conn_kw,
):
- HTTPConnectionPool.__init__(
- self,
+ super().__init__(
host,
port,
timeout,

MODIFY
src/urllib3/exceptions.py
src/urllib3/exceptions.py
@@ -20,7 +20,7 @@ class PoolError(HTTPError):
def __init__(self, pool, message):
self.pool = pool
- HTTPError.__init__(self, f"{pool}: {message}")
+ super().__init__(f"{pool}: {message}")
def __reduce__(self):
# For pickling purposes.
@@ -32,7 +32,7 @@ class RequestError(PoolError):
def __init__(self, pool, url, message):
self.url = url
- PoolError.__init__(self, pool, message)
+ super().__init__(pool, message)
def __reduce__(self):
# For pickling purposes.
@@ -87,7 +87,7 @@ class MaxRetryError(RequestError):
message = f"Max retries exceeded with url: {url} (Caused by {reason!r})"
- RequestError.__init__(self, pool, url, message)
+ super().__init__(pool, url, message)
class HostChangedError(RequestError):
@@ -95,7 +95,7 @@ class HostChangedError(RequestError):
def __init__(self, pool, url, retries=3):
message = f"Tried to open a foreign host with url: {url}"
- RequestError.__init__(self, pool, url, message)
+ super().__init__(pool, url, message)
self.retries = retries
@@ -158,7 +158,7 @@ class LocationParseError(LocationValueError):
def __init__(self, location):
message = f"Failed to parse: {location}"
- HTTPError.__init__(self, message)
+ super().__init__(message)
self.location = location

MODIFY
src/urllib3/poolmanager.py
src/urllib3/poolmanager.py
@@ -163,7 +163,7 @@ class PoolManager(RequestMethods):
proxy_config = None
def __init__(self, num_pools=10, headers=None, **connection_pool_kw):
- RequestMethods.__init__(self, headers)
+ super().__init__(headers)
self.connection_pool_kw = connection_pool_kw
self.pools = RecentlyUsedContainer(num_pools, dispose_func=lambda p: p.close())

Use super() from Python 3