Skip to content

Commit

Permalink
Simplify imports since requests >= 2.16.0 no longer uses vendored url…
Browse files Browse the repository at this point in the history
…lib3.

Signed-off-by: Felix Fontein <felix@fontein.de>
  • Loading branch information
felixfontein committed May 2, 2023
1 parent 8291c94 commit 115dbce
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 30 deletions.
10 changes: 3 additions & 7 deletions docker/transport/npipeconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
from .. import constants
from .npipesocket import NpipeSocket

try:
import requests.packages.urllib3 as urllib3
import requests.packages.urllib3.connection as urllib3_connection
except ImportError:
import urllib3
import urllib3.connection as urllib3_connection
import urllib3
import urllib3.connection

RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer


class NpipeHTTPConnection(urllib3_connection.HTTPConnection):
class NpipeHTTPConnection(urllib3.connection.HTTPConnection):
def __init__(self, npipe_path, timeout=60):
super().__init__(
'localhost', timeout=timeout
Expand Down
10 changes: 3 additions & 7 deletions docker/transport/sshconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
from docker.transport.basehttpadapter import BaseHTTPAdapter
from .. import constants

try:
import requests.packages.urllib3 as urllib3
import requests.packages.urllib3.connection as urllib3_connection
except ImportError:
import urllib3
import urllib3.connection as urllib3_connection
import urllib3
import urllib3.connection

RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer

Expand Down Expand Up @@ -99,7 +95,7 @@ def close(self):
self.proc.terminate()


class SSHConnection(urllib3_connection.HTTPConnection):
class SSHConnection(urllib3.connection.HTTPConnection):
def __init__(self, ssh_transport=None, timeout=60, host=None):
super().__init__(
'localhost', timeout=timeout
Expand Down
5 changes: 1 addition & 4 deletions docker/transport/ssladapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

from docker.transport.basehttpadapter import BaseHTTPAdapter

try:
import requests.packages.urllib3 as urllib3
except ImportError:
import urllib3
import urllib3


PoolManager = urllib3.poolmanager.PoolManager
Expand Down
10 changes: 3 additions & 7 deletions docker/transport/unixconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
from docker.transport.basehttpadapter import BaseHTTPAdapter
from .. import constants

try:
import requests.packages.urllib3 as urllib3
import requests.packages.urllib3.connection as urllib3_connection
except ImportError:
import urllib3
import urllib3.connection as urllib3_connection
import urllib3
import urllib3.connection


RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer


class UnixHTTPConnection(urllib3_connection.HTTPConnection):
class UnixHTTPConnection(urllib3.connection.HTTPConnection):

def __init__(self, base_url, unix_socket, timeout=60):
super().__init__(
Expand Down
5 changes: 1 addition & 4 deletions docker/types/daemon.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import socket

try:
import requests.packages.urllib3 as urllib3
except ImportError:
import urllib3
import urllib3

from ..errors import DockerException

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import docker
import pytest
import requests
import urllib3
from docker.api import APIClient
from docker.constants import DEFAULT_DOCKER_API_VERSION
from requests.packages import urllib3
from unittest import mock

from . import fake_api
Expand Down

0 comments on commit 115dbce

Please sign in to comment.