diff options
-rw-r--r-- | docker/api/build.py | 2 | ||||
-rw-r--r-- | docker/api/container.py | 13 | ||||
-rw-r--r-- | docker/api/image.py | 10 | ||||
-rw-r--r-- | docker/api/volume.py | 19 | ||||
-rw-r--r-- | docker/models/containers.py | 3 | ||||
-rw-r--r-- | docker/models/images.py | 5 | ||||
-rw-r--r-- | docker/models/plugins.py | 6 | ||||
-rw-r--r-- | docker/utils/utils.py | 1 | ||||
-rw-r--r-- | tests/integration/api_config_test.py | 2 | ||||
-rw-r--r-- | tests/unit/auth_test.py | 1 | ||||
-rw-r--r-- | tests/unit/utils_build_test.py | 24 |
11 files changed, 55 insertions, 31 deletions
diff --git a/docker/api/build.py b/docker/api/build.py index aac43c4..a48204a 100644 --- a/docker/api/build.py +++ b/docker/api/build.py @@ -153,7 +153,7 @@ class BuildApiMixin: with open(dockerignore) as f: exclude = list(filter( lambda x: x != '' and x[0] != '#', - [l.strip() for l in f.read().splitlines()] + [line.strip() for line in f.read().splitlines()] )) dockerfile = process_dockerfile(dockerfile, path) context = utils.tar( diff --git a/docker/api/container.py b/docker/api/container.py index 83fcd4f..17c0972 100644 --- a/docker/api/container.py +++ b/docker/api/container.py @@ -256,7 +256,9 @@ class ContainerApiMixin: .. code-block:: python - client.api.create_host_config(port_bindings={1111: ('127.0.0.1', 4567)}) + client.api.create_host_config( + port_bindings={1111: ('127.0.0.1', 4567)} + ) Or without host port assignment: @@ -579,10 +581,13 @@ class ContainerApiMixin: Example: - >>> client.api.create_host_config(privileged=True, cap_drop=['MKNOD'], - volumes_from=['nostalgic_newton']) + >>> client.api.create_host_config( + ... privileged=True, + ... cap_drop=['MKNOD'], + ... volumes_from=['nostalgic_newton'], + ... ) {'CapDrop': ['MKNOD'], 'LxcConf': None, 'Privileged': True, - 'VolumesFrom': ['nostalgic_newton'], 'PublishAllPorts': False} + 'VolumesFrom': ['nostalgic_newton'], 'PublishAllPorts': False} """ if not kwargs: diff --git a/docker/api/image.py b/docker/api/image.py index 772d889..5e1466e 100644 --- a/docker/api/image.py +++ b/docker/api/image.py @@ -377,7 +377,8 @@ class ImageApiMixin: Example: - >>> for line in client.api.pull('busybox', stream=True, decode=True): + >>> resp = client.api.pull('busybox', stream=True, decode=True) + ... for line in resp: ... print(json.dumps(line, indent=4)) { "status": "Pulling image (latest) from busybox", @@ -456,7 +457,12 @@ class ImageApiMixin: If the server returns an error. Example: - >>> for line in client.api.push('yourname/app', stream=True, decode=True): + >>> resp = client.api.push( + ... 'yourname/app', + ... stream=True, + ... decode=True, + ... ) + ... for line in resp: ... print(line) {'status': 'Pushing repository yourname/app (1 tags)'} {'status': 'Pushing','progressDetail': {}, 'id': '511136ea3c5a'} diff --git a/docker/api/volume.py b/docker/api/volume.py index 86b0018..98b42a1 100644 --- a/docker/api/volume.py +++ b/docker/api/volume.py @@ -56,15 +56,18 @@ class VolumeApiMixin: Example: - >>> volume = client.api.create_volume(name='foobar', driver='local', - driver_opts={'foo': 'bar', 'baz': 'false'}, - labels={"key": "value"}) - >>> print(volume) + >>> volume = client.api.create_volume( + ... name='foobar', + ... driver='local', + ... driver_opts={'foo': 'bar', 'baz': 'false'}, + ... labels={"key": "value"}, + ... ) + ... print(volume) {u'Driver': u'local', - u'Labels': {u'key': u'value'}, - u'Mountpoint': u'/var/lib/docker/volumes/foobar/_data', - u'Name': u'foobar', - u'Scope': u'local'} + u'Labels': {u'key': u'value'}, + u'Mountpoint': u'/var/lib/docker/volumes/foobar/_data', + u'Name': u'foobar', + u'Scope': u'local'} """ url = self._url('/volumes/create') diff --git a/docker/models/containers.py b/docker/models/containers.py index 957deed..e34659c 100644 --- a/docker/models/containers.py +++ b/docker/models/containers.py @@ -761,7 +761,8 @@ class ContainerCollection(Collection): {'/home/user1/': {'bind': '/mnt/vol2', 'mode': 'rw'}, '/var/www': {'bind': '/mnt/vol1', 'mode': 'ro'}} - Or a list of strings which each one of its elements specifies a mount volume. + Or a list of strings which each one of its elements specifies a + mount volume. For example: diff --git a/docker/models/images.py b/docker/models/images.py index 46f8efe..ef668c7 100644 --- a/docker/models/images.py +++ b/docker/models/images.py @@ -15,7 +15,10 @@ class Image(Model): An image on the server. """ def __repr__(self): - return "<{}: '{}'>".format(self.__class__.__name__, "', '".join(self.tags)) + return "<{}: '{}'>".format( + self.__class__.__name__, + "', '".join(self.tags), + ) @property def labels(self): diff --git a/docker/models/plugins.py b/docker/models/plugins.py index 37ecefb..69b94f3 100644 --- a/docker/models/plugins.py +++ b/docker/models/plugins.py @@ -117,7 +117,11 @@ class Plugin(Model): if remote is None: remote = self.name privileges = self.client.api.plugin_privileges(remote) - yield from self.client.api.upgrade_plugin(self.name, remote, privileges) + yield from self.client.api.upgrade_plugin( + self.name, + remote, + privileges, + ) self.reload() diff --git a/docker/utils/utils.py b/docker/utils/utils.py index 7b22909..71e4014 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -23,6 +23,7 @@ URLComponents = collections.namedtuple( 'scheme netloc url params query fragment', ) + def create_ipam_pool(*args, **kwargs): raise errors.DeprecatedMethod( 'utils.create_ipam_pool has been removed. Please use a ' diff --git a/tests/integration/api_config_test.py b/tests/integration/api_config_test.py index 82cb516..982ec46 100644 --- a/tests/integration/api_config_test.py +++ b/tests/integration/api_config_test.py @@ -73,7 +73,7 @@ class ConfigAPITest(BaseAPIIntegrationTest): def test_create_config_with_templating(self): config_id = self.client.create_config( 'favorite_character', 'sakuya izayoi', - templating={ 'name': 'golang'} + templating={'name': 'golang'} ) self.tmp_configs.append(config_id) assert 'ID' in config_id diff --git a/tests/unit/auth_test.py b/tests/unit/auth_test.py index ea953af..dd5b5f8 100644 --- a/tests/unit/auth_test.py +++ b/tests/unit/auth_test.py @@ -11,6 +11,7 @@ from docker import auth, credentials, errors from unittest import mock import pytest + class RegressionTest(unittest.TestCase): def test_803_urlsafe_encode(self): auth_data = { diff --git a/tests/unit/utils_build_test.py b/tests/unit/utils_build_test.py index 9f18388..fa7d833 100644 --- a/tests/unit/utils_build_test.py +++ b/tests/unit/utils_build_test.py @@ -272,8 +272,8 @@ class ExcludePathsTest(unittest.TestCase): assert self.exclude(['**/target/*/*']) == convert_paths( self.all_paths - { 'target/subdir/file.txt', - 'subdir/target/subdir/file.txt', - 'subdir/subdir2/target/subdir/file.txt' + 'subdir/target/subdir/file.txt', + 'subdir/subdir2/target/subdir/file.txt' } ) @@ -281,16 +281,16 @@ class ExcludePathsTest(unittest.TestCase): assert self.exclude(['subdir/**']) == convert_paths( self.all_paths - { 'subdir/file.txt', - 'subdir/target/file.txt', - 'subdir/target/subdir/file.txt', - 'subdir/subdir2/file.txt', - 'subdir/subdir2/target/file.txt', - 'subdir/subdir2/target/subdir/file.txt', - 'subdir/target', - 'subdir/target/subdir', - 'subdir/subdir2', - 'subdir/subdir2/target', - 'subdir/subdir2/target/subdir' + 'subdir/target/file.txt', + 'subdir/target/subdir/file.txt', + 'subdir/subdir2/file.txt', + 'subdir/subdir2/target/file.txt', + 'subdir/subdir2/target/subdir/file.txt', + 'subdir/target', + 'subdir/target/subdir', + 'subdir/subdir2', + 'subdir/subdir2/target', + 'subdir/subdir2/target/subdir' } ) |