Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Ruff, fix some minor issues #3206

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: pip install -U ruff==0.0.284
- run: pip install -U ruff==0.1.8
- name: Run ruff
run: ruff docker tests

Expand Down
6 changes: 3 additions & 3 deletions docker/models/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,9 @@ def run(self, image, command=None, stdout=True, stderr=False,
container, exit_status, command, image, out
)

return out if stream or out is None else b''.join(
[line for line in out]
)
if stream or out is None:
return out
return b''.join(out)

def create(self, image, command=None, **kwargs):
"""
Expand Down
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
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
setuptools==65.5.1
coverage==7.2.7
ruff==0.0.284
ruff==0.1.8
pytest==7.4.2
pytest-cov==4.1.0
pytest-timeout==2.1.0
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