mirror of https://github.com/docker/docker-py.git
Enable Ruff B rules and autofix
Signed-off-by: Aarni Koskela <akx@iki.fi>
This commit is contained in:
parent
601476733c
commit
8447f7b0f0
|
@ -187,7 +187,7 @@ class PluginCollection(Collection):
|
|||
"""
|
||||
privileges = self.client.api.plugin_privileges(remote_name)
|
||||
it = self.client.api.pull_plugin(remote_name, privileges, local_name)
|
||||
for data in it:
|
||||
for _data in it:
|
||||
pass
|
||||
return self.get(local_name or remote_name)
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ def read(socket, n=4096):
|
|||
try:
|
||||
if hasattr(socket, 'recv'):
|
||||
return socket.recv(n)
|
||||
if isinstance(socket, getattr(pysocket, 'SocketIO')):
|
||||
if isinstance(socket, pysocket.SocketIO):
|
||||
return socket.read(n)
|
||||
return os.read(socket.fileno(), n)
|
||||
except OSError as e:
|
||||
|
|
|
@ -7,6 +7,7 @@ write_to = 'docker/_version.py'
|
|||
[tool.ruff]
|
||||
target-version = "py37"
|
||||
extend-select = [
|
||||
"B",
|
||||
"C",
|
||||
"F",
|
||||
"W",
|
||||
|
|
|
@ -132,7 +132,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
path=base_dir,
|
||||
tag=tag,
|
||||
)
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
c = self.client.create_container(tag, ['find', '/test', '-type', 'f'])
|
||||
|
@ -160,7 +160,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, tag='buildargs', buildargs={'test': 'OK'}
|
||||
)
|
||||
self.tmp_imgs.append('buildargs')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
info = self.client.inspect_image('buildargs')
|
||||
|
@ -180,7 +180,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, tag=tag, shmsize=shmsize
|
||||
)
|
||||
self.tmp_imgs.append(tag)
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
# There is currently no way to get the shmsize
|
||||
|
@ -198,7 +198,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
isolation='default'
|
||||
)
|
||||
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
@requires_api_version('1.23')
|
||||
|
@ -213,7 +213,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, tag='labels', labels=labels
|
||||
)
|
||||
self.tmp_imgs.append('labels')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
info = self.client.inspect_image('labels')
|
||||
|
@ -230,7 +230,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
|
||||
stream = self.client.build(fileobj=script, tag='build1')
|
||||
self.tmp_imgs.append('build1')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
stream = self.client.build(
|
||||
|
@ -271,7 +271,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, target='first', tag='build1'
|
||||
)
|
||||
self.tmp_imgs.append('build1')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
info = self.client.inspect_image('build1')
|
||||
|
@ -300,7 +300,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
)
|
||||
|
||||
self.tmp_imgs.append('dockerpytest_customnetbuild')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
assert self.client.inspect_image('dockerpytest_customnetbuild')
|
||||
|
@ -365,7 +365,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, tag=tag, squash=squash
|
||||
)
|
||||
self.tmp_imgs.append(tag)
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
return self.client.inspect_image(tag)
|
||||
|
|
|
@ -39,7 +39,7 @@ class PluginTest(BaseAPIIntegrationTest):
|
|||
return self.client.inspect_plugin(plugin_name)
|
||||
except docker.errors.NotFound:
|
||||
prv = self.client.plugin_privileges(plugin_name)
|
||||
for d in self.client.pull_plugin(plugin_name, prv):
|
||||
for _d in self.client.pull_plugin(plugin_name, prv):
|
||||
pass
|
||||
return self.client.inspect_plugin(plugin_name)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class TestRegressions(BaseAPIIntegrationTest):
|
|||
def test_443_handle_nonchunked_response_in_stream(self):
|
||||
dfile = io.BytesIO()
|
||||
with pytest.raises(docker.errors.APIError) as exc:
|
||||
for line in self.client.build(fileobj=dfile, tag="a/b/c"):
|
||||
for _line in self.client.build(fileobj=dfile, tag="a/b/c"):
|
||||
pass
|
||||
assert exc.value.is_error()
|
||||
dfile.close()
|
||||
|
|
|
@ -124,7 +124,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
path=base_dir,
|
||||
tag=tag,
|
||||
)
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
c = self.client.create_container(tag, ['find', '/test', '-type', 'f'])
|
||||
|
@ -151,7 +151,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, tag='buildargs', buildargs={'test': 'OK'}
|
||||
)
|
||||
self.tmp_imgs.append('buildargs')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
info = self.client.inspect_image('buildargs')
|
||||
|
@ -171,7 +171,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, tag=tag, shmsize=shmsize
|
||||
)
|
||||
self.tmp_imgs.append(tag)
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
# There is currently no way to get the shmsize
|
||||
|
@ -189,7 +189,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
isolation='default'
|
||||
)
|
||||
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
@requires_api_version('1.23')
|
||||
|
@ -204,7 +204,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, tag='labels', labels=labels
|
||||
)
|
||||
self.tmp_imgs.append('labels')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
info = self.client.inspect_image('labels')
|
||||
|
@ -221,7 +221,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
|
||||
stream = self.client.build(fileobj=script, tag='build1')
|
||||
self.tmp_imgs.append('build1')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
stream = self.client.build(
|
||||
|
@ -262,7 +262,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, target='first', tag='build1'
|
||||
)
|
||||
self.tmp_imgs.append('build1')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
info = self.client.inspect_image('build1')
|
||||
|
@ -291,7 +291,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
)
|
||||
|
||||
self.tmp_imgs.append('dockerpytest_customnetbuild')
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
assert self.client.inspect_image('dockerpytest_customnetbuild')
|
||||
|
@ -356,7 +356,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
|||
fileobj=script, tag=tag, squash=squash
|
||||
)
|
||||
self.tmp_imgs.append(tag)
|
||||
for chunk in stream:
|
||||
for _chunk in stream:
|
||||
pass
|
||||
|
||||
return self.client.inspect_image(tag)
|
||||
|
|
|
@ -333,8 +333,8 @@ class DockerApiTest(BaseAPIClientTest):
|
|||
|
||||
# mock a stream interface
|
||||
raw_resp = urllib3.HTTPResponse(body=body)
|
||||
setattr(raw_resp._fp, 'chunked', True)
|
||||
setattr(raw_resp._fp, 'chunk_left', len(body.getvalue()) - 1)
|
||||
raw_resp._fp.chunked = True
|
||||
raw_resp._fp.chunk_left = len(body.getvalue()) - 1
|
||||
|
||||
# pass `decode=False` to the helper
|
||||
raw_resp._fp.seek(0)
|
||||
|
@ -349,7 +349,7 @@ class DockerApiTest(BaseAPIClientTest):
|
|||
assert result == content
|
||||
|
||||
# non-chunked response, pass `decode=False` to the helper
|
||||
setattr(raw_resp._fp, 'chunked', False)
|
||||
raw_resp._fp.chunked = False
|
||||
raw_resp._fp.seek(0)
|
||||
resp = response(status_code=status_code, content=content, raw=raw_resp)
|
||||
result = next(self.client._stream_helper(resp))
|
||||
|
|
Loading…
Reference in New Issue