Skip to content

Commit 08956b5

Browse files
authored
ci: update Ruff & fix some minor issues (#3206)
Signed-off-by: Aarni Koskela <akx@iki.fi>
1 parent b8a6987 commit 08956b5

File tree

9 files changed

+14
-16
lines changed

9 files changed

+14
-16
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/setup-python@v4
1515
with:
1616
python-version: '3.x'
17-
- run: pip install -U ruff==0.0.284
17+
- run: pip install -U ruff==0.1.8
1818
- name: Run ruff
1919
run: ruff docker tests
2020

docker/models/containers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,9 @@ def run(self, image, command=None, stdout=True, stderr=False,
903903
container, exit_status, command, image, out
904904
)
905905

906-
return out if stream or out is None else b''.join(
907-
[line for line in out]
908-
)
906+
if stream or out is None:
907+
return out
908+
return b''.join(out)
909909

910910
def create(self, image, command=None, **kwargs):
911911
"""

docker/utils/socket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def read_exactly(socket, n):
6464
Reads exactly n bytes from socket
6565
Raises SocketError if there isn't enough data
6666
"""
67-
data = bytes()
67+
data = b""
6868
while len(data) < n:
6969
next_data = read(socket, n - len(data))
7070
if not next_data:
@@ -152,7 +152,7 @@ def consume_socket_output(frames, demux=False):
152152
if demux is False:
153153
# If the streams are multiplexed, the generator returns strings, that
154154
# we just need to concatenate.
155-
return bytes().join(frames)
155+
return b"".join(frames)
156156

157157
# If the streams are demultiplexed, the generator yields tuples
158158
# (stdout, stderr)

docker/utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def convert_volume_binds(binds):
152152
]
153153
if 'propagation' in v and v['propagation'] in propagation_modes:
154154
if mode:
155-
mode = ','.join([mode, v['propagation']])
155+
mode = f"{mode},{v['propagation']}"
156156
else:
157157
mode = v['propagation']
158158

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
55
write_to = 'docker/_version.py'
66

77
[tool.ruff]
8-
target-version = "py37"
8+
target-version = "py38"
99
extend-select = [
1010
"B",
1111
"C",
1212
"F",
13+
"UP",
1314
"W",
1415
]
1516
ignore = [
17+
"UP012", # unnecessary `UTF-8` argument (we want to be explicit)
1618
"C901", # too complex (there's a whole bunch of these)
1719
]
1820

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
setuptools==65.5.1
22
coverage==7.2.7
3-
ruff==0.0.284
3+
ruff==0.1.8
44
pytest==7.4.2
55
pytest-cov==4.1.0
66
pytest-timeout==2.1.0

tests/integration/api_build_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,7 @@ def test_build_stderr_data(self):
389389
lines = []
390390
for chunk in stream:
391391
lines.append(chunk.get('stream'))
392-
expected = '{0}{2}\n{1}'.format(
393-
control_chars[0], control_chars[1], snippet
394-
)
392+
expected = f'{control_chars[0]}{snippet}\n{control_chars[1]}'
395393
assert any(line == expected for line in lines)
396394

397395
def test_build_gzip_encoding(self):

tests/ssh/api_build_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,7 @@ def test_build_stderr_data(self):
380380
lines = []
381381
for chunk in stream:
382382
lines.append(chunk.get('stream'))
383-
expected = '{0}{2}\n{1}'.format(
384-
control_chars[0], control_chars[1], snippet
385-
)
383+
expected = f'{control_chars[0]}{snippet}\n{control_chars[1]}'
386384
assert any(line == expected for line in lines)
387385

388386
def test_build_gzip_encoding(self):

tests/unit/api_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def fake_delete(self, url, *args, **kwargs):
8282

8383

8484
def fake_read_from_socket(self, response, stream, tty=False, demux=False):
85-
return bytes()
85+
return b''
8686

8787

8888
url_base = f'{fake_api.prefix}/'

0 commit comments

Comments
 (0)