From 3ffdd8a1c52cb7677d926feaf1a44d585a066dac Mon Sep 17 00:00:00 2001 From: Milas Bowman Date: Tue, 26 Jul 2022 13:48:47 -0400 Subject: lint: fix outstanding flake8 violations Since flake8 wasn't actually being run in CI, we'd accumulated some violations. Signed-off-by: Milas Bowman --- docker/api/build.py | 2 +- docker/api/container.py | 13 +++++++++---- docker/api/image.py | 10 ++++++++-- docker/api/volume.py | 19 +++++++++++-------- docker/models/containers.py | 3 ++- docker/models/images.py | 5 ++++- docker/models/plugins.py | 6 +++++- docker/utils/utils.py | 1 + 8 files changed, 41 insertions(+), 18 deletions(-) (limited to 'docker') 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 ' -- cgit v1.2.1