Skip to content

Commit

Permalink
lint: fix outstanding flake8 violations
Browse files Browse the repository at this point in the history
Since flake8 wasn't actually being run in CI, we'd accumulated some
violations.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
  • Loading branch information
milas committed Jul 26, 2022
1 parent ce40d4b commit 3ffdd8a
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docker/api/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
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(
Expand Down
13 changes: 9 additions & 4 deletions docker/api/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ def create_container(self, image, command=None, hostname=None, user=None,
.. 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:
Expand Down Expand Up @@ -579,10 +581,13 @@ def create_host_config(self, *args, **kwargs):
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:
Expand Down
10 changes: 8 additions & 2 deletions docker/api/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ def pull(self, repository, tag=None, stream=False, auth_config=None,
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",
Expand Down Expand Up @@ -456,7 +457,12 @@ def push(self, repository, tag=None, stream=False, auth_config=None,
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'}
Expand Down
19 changes: 11 additions & 8 deletions docker/api/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ def create_volume(self, name=None, driver=None, driver_opts=None,
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')
Expand Down
3 changes: 2 additions & 1 deletion docker/models/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,8 @@ def run(self, image, command=None, stdout=True, stderr=False,
{'/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:
Expand Down
5 changes: 4 additions & 1 deletion docker/models/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion docker/models/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ def upgrade(self, remote=None):
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()


Expand Down
1 change: 1 addition & 0 deletions docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'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 '
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_list_configs(self):
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
Expand Down
1 change: 1 addition & 0 deletions tests/unit/auth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from unittest import mock
import pytest


class RegressionTest(unittest.TestCase):
def test_803_urlsafe_encode(self):
auth_data = {
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/utils_build_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,25 +272,25 @@ def test_single_and_double_wildcard(self):
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'
}
)

def test_trailing_double_wildcard(self):
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'
}
)

Expand Down

0 comments on commit 3ffdd8a

Please sign in to comment.