Skip to content

Commit 8447f7b

Browse files
committed
Enable Ruff B rules and autofix
Signed-off-by: Aarni Koskela <akx@iki.fi>
1 parent 6014767 commit 8447f7b

File tree

8 files changed

+26
-25
lines changed

8 files changed

+26
-25
lines changed

docker/models/plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def install(self, remote_name, local_name=None):
187187
"""
188188
privileges = self.client.api.plugin_privileges(remote_name)
189189
it = self.client.api.pull_plugin(remote_name, privileges, local_name)
190-
for data in it:
190+
for _data in it:
191191
pass
192192
return self.get(local_name or remote_name)
193193

docker/utils/socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def read(socket, n=4096):
4242
try:
4343
if hasattr(socket, 'recv'):
4444
return socket.recv(n)
45-
if isinstance(socket, getattr(pysocket, 'SocketIO')):
45+
if isinstance(socket, pysocket.SocketIO):
4646
return socket.read(n)
4747
return os.read(socket.fileno(), n)
4848
except OSError as e:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ write_to = 'docker/_version.py'
77
[tool.ruff]
88
target-version = "py37"
99
extend-select = [
10+
"B",
1011
"C",
1112
"F",
1213
"W",

tests/integration/api_build_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_build_with_dockerignore(self):
132132
path=base_dir,
133133
tag=tag,
134134
)
135-
for chunk in stream:
135+
for _chunk in stream:
136136
pass
137137

138138
c = self.client.create_container(tag, ['find', '/test', '-type', 'f'])
@@ -160,7 +160,7 @@ def test_build_with_buildargs(self):
160160
fileobj=script, tag='buildargs', buildargs={'test': 'OK'}
161161
)
162162
self.tmp_imgs.append('buildargs')
163-
for chunk in stream:
163+
for _chunk in stream:
164164
pass
165165

166166
info = self.client.inspect_image('buildargs')
@@ -180,7 +180,7 @@ def test_build_shmsize(self):
180180
fileobj=script, tag=tag, shmsize=shmsize
181181
)
182182
self.tmp_imgs.append(tag)
183-
for chunk in stream:
183+
for _chunk in stream:
184184
pass
185185

186186
# There is currently no way to get the shmsize
@@ -198,7 +198,7 @@ def test_build_isolation(self):
198198
isolation='default'
199199
)
200200

201-
for chunk in stream:
201+
for _chunk in stream:
202202
pass
203203

204204
@requires_api_version('1.23')
@@ -213,7 +213,7 @@ def test_build_labels(self):
213213
fileobj=script, tag='labels', labels=labels
214214
)
215215
self.tmp_imgs.append('labels')
216-
for chunk in stream:
216+
for _chunk in stream:
217217
pass
218218

219219
info = self.client.inspect_image('labels')
@@ -230,7 +230,7 @@ def test_build_with_cache_from(self):
230230

231231
stream = self.client.build(fileobj=script, tag='build1')
232232
self.tmp_imgs.append('build1')
233-
for chunk in stream:
233+
for _chunk in stream:
234234
pass
235235

236236
stream = self.client.build(
@@ -271,7 +271,7 @@ def test_build_container_with_target(self):
271271
fileobj=script, target='first', tag='build1'
272272
)
273273
self.tmp_imgs.append('build1')
274-
for chunk in stream:
274+
for _chunk in stream:
275275
pass
276276

277277
info = self.client.inspect_image('build1')
@@ -300,7 +300,7 @@ def test_build_with_network_mode(self):
300300
)
301301

302302
self.tmp_imgs.append('dockerpytest_customnetbuild')
303-
for chunk in stream:
303+
for _chunk in stream:
304304
pass
305305

306306
assert self.client.inspect_image('dockerpytest_customnetbuild')
@@ -365,7 +365,7 @@ def build_squashed(squash):
365365
fileobj=script, tag=tag, squash=squash
366366
)
367367
self.tmp_imgs.append(tag)
368-
for chunk in stream:
368+
for _chunk in stream:
369369
pass
370370

371371
return self.client.inspect_image(tag)

tests/integration/api_plugin_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def ensure_plugin_installed(self, plugin_name):
3939
return self.client.inspect_plugin(plugin_name)
4040
except docker.errors.NotFound:
4141
prv = self.client.plugin_privileges(plugin_name)
42-
for d in self.client.pull_plugin(plugin_name, prv):
42+
for _d in self.client.pull_plugin(plugin_name, prv):
4343
pass
4444
return self.client.inspect_plugin(plugin_name)
4545

tests/integration/regression_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TestRegressions(BaseAPIIntegrationTest):
1212
def test_443_handle_nonchunked_response_in_stream(self):
1313
dfile = io.BytesIO()
1414
with pytest.raises(docker.errors.APIError) as exc:
15-
for line in self.client.build(fileobj=dfile, tag="a/b/c"):
15+
for _line in self.client.build(fileobj=dfile, tag="a/b/c"):
1616
pass
1717
assert exc.value.is_error()
1818
dfile.close()

tests/ssh/api_build_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_build_with_dockerignore(self):
124124
path=base_dir,
125125
tag=tag,
126126
)
127-
for chunk in stream:
127+
for _chunk in stream:
128128
pass
129129

130130
c = self.client.create_container(tag, ['find', '/test', '-type', 'f'])
@@ -151,7 +151,7 @@ def test_build_with_buildargs(self):
151151
fileobj=script, tag='buildargs', buildargs={'test': 'OK'}
152152
)
153153
self.tmp_imgs.append('buildargs')
154-
for chunk in stream:
154+
for _chunk in stream:
155155
pass
156156

157157
info = self.client.inspect_image('buildargs')
@@ -171,7 +171,7 @@ def test_build_shmsize(self):
171171
fileobj=script, tag=tag, shmsize=shmsize
172172
)
173173
self.tmp_imgs.append(tag)
174-
for chunk in stream:
174+
for _chunk in stream:
175175
pass
176176

177177
# There is currently no way to get the shmsize
@@ -189,7 +189,7 @@ def test_build_isolation(self):
189189
isolation='default'
190190
)
191191

192-
for chunk in stream:
192+
for _chunk in stream:
193193
pass
194194

195195
@requires_api_version('1.23')
@@ -204,7 +204,7 @@ def test_build_labels(self):
204204
fileobj=script, tag='labels', labels=labels
205205
)
206206
self.tmp_imgs.append('labels')
207-
for chunk in stream:
207+
for _chunk in stream:
208208
pass
209209

210210
info = self.client.inspect_image('labels')
@@ -221,7 +221,7 @@ def test_build_with_cache_from(self):
221221

222222
stream = self.client.build(fileobj=script, tag='build1')
223223
self.tmp_imgs.append('build1')
224-
for chunk in stream:
224+
for _chunk in stream:
225225
pass
226226

227227
stream = self.client.build(
@@ -262,7 +262,7 @@ def test_build_container_with_target(self):
262262
fileobj=script, target='first', tag='build1'
263263
)
264264
self.tmp_imgs.append('build1')
265-
for chunk in stream:
265+
for _chunk in stream:
266266
pass
267267

268268
info = self.client.inspect_image('build1')
@@ -291,7 +291,7 @@ def test_build_with_network_mode(self):
291291
)
292292

293293
self.tmp_imgs.append('dockerpytest_customnetbuild')
294-
for chunk in stream:
294+
for _chunk in stream:
295295
pass
296296

297297
assert self.client.inspect_image('dockerpytest_customnetbuild')
@@ -356,7 +356,7 @@ def build_squashed(squash):
356356
fileobj=script, tag=tag, squash=squash
357357
)
358358
self.tmp_imgs.append(tag)
359-
for chunk in stream:
359+
for _chunk in stream:
360360
pass
361361

362362
return self.client.inspect_image(tag)

tests/unit/api_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ def test_stream_helper_decoding(self):
333333

334334
# mock a stream interface
335335
raw_resp = urllib3.HTTPResponse(body=body)
336-
setattr(raw_resp._fp, 'chunked', True)
337-
setattr(raw_resp._fp, 'chunk_left', len(body.getvalue()) - 1)
336+
raw_resp._fp.chunked = True
337+
raw_resp._fp.chunk_left = len(body.getvalue()) - 1
338338

339339
# pass `decode=False` to the helper
340340
raw_resp._fp.seek(0)
@@ -349,7 +349,7 @@ def test_stream_helper_decoding(self):
349349
assert result == content
350350

351351
# non-chunked response, pass `decode=False` to the helper
352-
setattr(raw_resp._fp, 'chunked', False)
352+
raw_resp._fp.chunked = False
353353
raw_resp._fp.seek(0)
354354
resp = response(status_code=status_code, content=content, raw=raw_resp)
355355
result = next(self.client._stream_helper(resp))

0 commit comments

Comments
 (0)