chore: ruff cleanup — fix 7 long-standing lint findings

Mechanical, no behavior change. `ruff check src/ tests/` now passes
with zero findings.

- cli.py:147 (SIM105) — replace `try/except SynologyError/pass` around
  the cleanup logout with `contextlib.suppress(SynologyError)`.
- compose.py:271 (B007) — drop the unused `i` from the env_list
  preview-detection loop (the apply loop below still uses enumerate).
- compose.py:329 (E501) — extract `verb = "Updated" if … else "Added"`
  into a local before the return so the f-string fits in 100 cols.
- images.py:237 (E501) — extract `stopped_name = in_use_stopped[0]`
  before the return and split the message across two f-strings.
- test_auth.py:38, 127, 140 (SIM117) — combine nested `with patch(…):`
  / `with pytest.raises(…):` into single parenthesised with-statements.

236 tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 09:15:50 +02:00
parent 8878eda0b2
commit 6ba4c7ca92
4 changed files with 23 additions and 15 deletions
+15 -9
View File
@@ -35,9 +35,11 @@ def test_resolve_credentials_no_credentials(monkeypatch):
config = make_config()
auth = AuthManager(config)
with patch("keyring.get_password", return_value=None):
with pytest.raises(AuthenticationError, match="No credentials found"):
auth.resolve_credentials()
with (
patch("keyring.get_password", return_value=None),
pytest.raises(AuthenticationError, match="No credentials found"),
):
auth.resolve_credentials()
def test_resolve_credentials_from_keyring(monkeypatch):
@@ -124,9 +126,11 @@ async def test_login_2fa_required():
mock_client = AsyncMock()
mock_client.request.side_effect = SynologyError("2FA required", code=403)
with patch.object(auth, "resolve_credentials", return_value=("user", "pass", None)):
with pytest.raises(AuthenticationError, match="2FA is required"):
await auth.login(mock_client)
with (
patch.object(auth, "resolve_credentials", return_value=("user", "pass", None)),
pytest.raises(AuthenticationError, match="2FA is required"),
):
await auth.login(mock_client)
@pytest.mark.asyncio
@@ -137,9 +141,11 @@ async def test_login_no_sid_returned():
mock_client = AsyncMock()
mock_client.request.return_value = {} # No 'sid' key
with patch.object(auth, "resolve_credentials", return_value=("user", "pass", None)):
with pytest.raises(AuthenticationError, match="no session ID"):
await auth.login(mock_client)
with (
patch.object(auth, "resolve_credentials", return_value=("user", "pass", None)),
pytest.raises(AuthenticationError, match="no session ID"),
):
await auth.login(mock_client)
@pytest.mark.asyncio