Skip to content

Commit

Permalink
Correct Ruff target version, enable UP, autofix
Browse files Browse the repository at this point in the history
Signed-off-by: Aarni Koskela <[email protected]>
  • Loading branch information
akx committed Dec 21, 2023
1 parent b981eab commit e17a0ac
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docker/utils/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def read_exactly(socket, n):
Reads exactly n bytes from socket
Raises SocketError if there isn't enough data
"""
data = bytes()
data = b""
while len(data) < n:
next_data = read(socket, n - len(data))
if not next_data:
Expand Down Expand Up @@ -152,7 +152,7 @@ def consume_socket_output(frames, demux=False):
if demux is False:
# If the streams are multiplexed, the generator returns strings, that
# we just need to concatenate.
return bytes().join(frames)
return b"".join(frames)

# If the streams are demultiplexed, the generator yields tuples
# (stdout, stderr)
Expand Down
2 changes: 1 addition & 1 deletion docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def convert_volume_binds(binds):
]
if 'propagation' in v and v['propagation'] in propagation_modes:
if mode:
mode = ','.join([mode, v['propagation']])
mode = f"{mode},{v['propagation']}"
else:
mode = v['propagation']

Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
write_to = 'docker/_version.py'

[tool.ruff]
target-version = "py37"
target-version = "py38"
extend-select = [
"B",
"C",
"F",
"UP",
"W",
]
ignore = [
"UP012", # unnecessary `UTF-8` argument (we want to be explicit)
"C901", # too complex (there's a whole bunch of these)
]

Expand Down
4 changes: 1 addition & 3 deletions tests/integration/api_build_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,7 @@ def test_build_stderr_data(self):
lines = []
for chunk in stream:
lines.append(chunk.get('stream'))
expected = '{0}{2}\n{1}'.format(
control_chars[0], control_chars[1], snippet
)
expected = f'{control_chars[0]}{snippet}\n{control_chars[1]}'
assert any(line == expected for line in lines)

def test_build_gzip_encoding(self):
Expand Down
4 changes: 1 addition & 3 deletions tests/ssh/api_build_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,7 @@ def test_build_stderr_data(self):
lines = []
for chunk in stream:
lines.append(chunk.get('stream'))
expected = '{0}{2}\n{1}'.format(
control_chars[0], control_chars[1], snippet
)
expected = f'{control_chars[0]}{snippet}\n{control_chars[1]}'
assert any(line == expected for line in lines)

def test_build_gzip_encoding(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def fake_delete(self, url, *args, **kwargs):


def fake_read_from_socket(self, response, stream, tty=False, demux=False):
return bytes()
return b''


url_base = f'{fake_api.prefix}/'
Expand Down

0 comments on commit e17a0ac

Please sign in to comment.