Skip to content

Commit bd2d7d9

Browse files
committed
refact: ruff fixes
1 parent 2d6b891 commit bd2d7d9

File tree

20 files changed

+107
-115
lines changed

20 files changed

+107
-115
lines changed

packages/hop3-cli/tests/test_local_commands.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def mock_printer(self):
199199

200200
def test_init_help(self, temp_config, mock_printer, capsys):
201201
"""Test init --help shows help."""
202-
result = handle_init(["--help"], temp_config, mock_printer)
202+
handle_init(["--help"], temp_config, mock_printer)
203203

204204
captured = capsys.readouterr()
205205
assert "Usage: hop3 init --ssh" in captured.out
@@ -233,7 +233,7 @@ def test_init_success(self, temp_config, mock_printer, capsys):
233233
),
234234
patch("builtins.input", side_effect=["admin", "admin@example.com", ""]),
235235
):
236-
result = handle_init(
236+
handle_init(
237237
["--ssh", "root@test.com", "-y"],
238238
temp_config,
239239
mock_printer,
@@ -263,7 +263,7 @@ def mock_printer(self):
263263

264264
def test_login_help(self, temp_config, mock_printer, capsys):
265265
"""Test login --help shows help."""
266-
result = handle_login(["--help"], temp_config, mock_printer)
266+
handle_login(["--help"], temp_config, mock_printer)
267267

268268
captured = capsys.readouterr()
269269
assert "Usage: hop3 login" in captured.out
@@ -287,7 +287,7 @@ def test_login_ssh_success(self, temp_config, mock_printer, capsys):
287287
),
288288
patch("builtins.input", return_value="testuser"), # username
289289
):
290-
result = handle_login(
290+
handle_login(
291291
["--ssh", "root@test.com"],
292292
temp_config,
293293
mock_printer,
@@ -313,7 +313,7 @@ def test_login_token_success(self, temp_config, mock_printer, capsys):
313313
with patch(
314314
"hop3_cli.commands.local.login_cmd._verify_token", return_value="testuser"
315315
):
316-
result = handle_login_token(
316+
handle_login_token(
317317
["--token", mock_token, "--server", "http://localhost:8000"],
318318
temp_config,
319319
mock_printer,
@@ -338,7 +338,7 @@ def test_login_token_with_existing_server(self, temp_config, mock_printer, capsy
338338
with patch(
339339
"hop3_cli.commands.local.login_cmd._verify_token", return_value="testuser"
340340
):
341-
result = handle_login_token(
341+
handle_login_token(
342342
["--token", mock_token],
343343
temp_config,
344344
mock_printer,
@@ -386,7 +386,7 @@ def test_login_url_with_token(self, temp_config, mock_printer, capsys):
386386
with patch(
387387
"hop3_cli.commands.local.login_cmd._verify_token", return_value="testuser"
388388
):
389-
result = handle_login([url_with_token], temp_config, mock_printer)
389+
handle_login([url_with_token], temp_config, mock_printer)
390390

391391
# Credentials are saved to a "default" context when no context exists
392392
default_ctx = temp_config.data["contexts"]["default"]
@@ -403,7 +403,7 @@ def test_login_url_with_token_and_path(self, temp_config, mock_printer, capsys):
403403
with patch(
404404
"hop3_cli.commands.local.login_cmd._verify_token", return_value="testuser"
405405
):
406-
result = handle_login([url_with_token], temp_config, mock_printer)
406+
handle_login([url_with_token], temp_config, mock_printer)
407407

408408
# Credentials are saved to a "default" context when no context exists
409409
default_ctx = temp_config.data["contexts"]["default"]
@@ -429,7 +429,7 @@ def mock_printer(self):
429429

430430
def test_version_shows_cli_version(self, temp_config, mock_printer, capsys):
431431
"""Test version command shows CLI version."""
432-
result = handle_version([], temp_config, mock_printer)
432+
handle_version([], temp_config, mock_printer)
433433

434434
captured = capsys.readouterr()
435435
assert "hop3-cli" in captured.out
@@ -453,7 +453,7 @@ def mock_printer(self):
453453

454454
def test_auth_shows_help(self, temp_config, mock_printer, capsys):
455455
"""Test auth command shows authentication help."""
456-
result = handle_auth([], temp_config, mock_printer)
456+
handle_auth([], temp_config, mock_printer)
457457

458458
captured = capsys.readouterr()
459459
assert "Authentication commands" in captured.out
@@ -462,7 +462,7 @@ def test_auth_shows_help(self, temp_config, mock_printer, capsys):
462462

463463
def test_auth_with_help_flag(self, temp_config, mock_printer, capsys):
464464
"""Test auth --help shows help."""
465-
result = handle_auth(["--help"], temp_config, mock_printer)
465+
handle_auth(["--help"], temp_config, mock_printer)
466466

467467
captured = capsys.readouterr()
468468
assert "Authentication commands" in captured.out

packages/hop3-cli/tests/test_rich_printer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def test_rich_printer_unknown_message_type():
261261
printer.print([{"t": "unknown", "data": "something"}])
262262

263263
# Should produce some output or handle gracefully
264-
output = stdout_capture.getvalue()
264+
stdout_capture.getvalue()
265265
# Unknown types might be printed as-is or ignored
266266
# Implementation-specific behavior
267267

packages/hop3-server/tests/a_unit/cli/test_admin_cli.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright (c) 2025, Abilian SAS
22
#
33
# SPDX-License-Identifier: Apache-2.0
4-
# ruff: noqa: PT012
54

65
"""Tests for server-side CLI admin commands (hop3-server admin:*)."""
76

@@ -139,7 +138,7 @@ def test_create_admin_username_exists(self, mock_user, monkeypatch):
139138
),
140139
pytest.raises(SystemExit) as exc_info,
141140
):
142-
cmd = AdminCreate() # noqa: PT012
141+
cmd = AdminCreate()
143142
cmd.run(username="testuser", email="new@example.com", password_stdin=False)
144143

145144
assert exc_info.value.code == 1
@@ -160,7 +159,7 @@ def test_create_admin_password_mismatch(self, monkeypatch):
160159
),
161160
pytest.raises(SystemExit) as exc_info,
162161
):
163-
cmd = AdminCreate() # noqa: PT012
162+
cmd = AdminCreate()
164163
cmd.run(
165164
username="newadmin", email="admin@example.com", password_stdin=False
166165
)
@@ -208,7 +207,7 @@ def test_generate_token_user_not_found(self, monkeypatch):
208207
patch("hop3.server.cli.admin.get_session", return_value=mock_session),
209208
pytest.raises(SystemExit) as exc_info,
210209
):
211-
cmd = AdminToken() # noqa: PT012
210+
cmd = AdminToken()
212211
cmd.run(username="nonexistent")
213212

214213
assert exc_info.value.code == 1
@@ -229,7 +228,7 @@ def test_generate_token_disabled_user(self, mock_user, monkeypatch):
229228
patch("hop3.server.cli.admin.get_session", return_value=mock_session),
230229
pytest.raises(SystemExit) as exc_info,
231230
):
232-
cmd = AdminToken() # noqa: PT012
231+
cmd = AdminToken()
233232
cmd.run(username="testuser")
234233

235234
assert exc_info.value.code == 1
@@ -357,7 +356,7 @@ def test_reset_password_user_not_found(self, monkeypatch):
357356
),
358357
pytest.raises(SystemExit) as exc_info,
359358
):
360-
cmd = AdminResetPassword() # noqa: PT012
359+
cmd = AdminResetPassword()
361360
cmd.run(username="nonexistent", password_stdin=False)
362361

363362
assert exc_info.value.code == 1

packages/hop3-server/tests/a_unit/commands/test_config_migrate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_migrate_procfile_with_backup(tmp_path):
187187
procfile_path.write_text(procfile_content)
188188

189189
cmd = MigrateCmd()
190-
result = cmd.call("procfile", str(tmp_path), dry_run=False, backup=True)
190+
cmd.call("procfile", str(tmp_path), dry_run=False, backup=True)
191191

192192
# Check backup was created
193193
backup = tmp_path / "Procfile.bak"
@@ -208,7 +208,7 @@ def test_migrate_procfile_no_backup(tmp_path):
208208
procfile_path.write_text(procfile_content)
209209

210210
cmd = MigrateCmd()
211-
result = cmd.call("procfile", str(tmp_path), dry_run=False, backup=False)
211+
cmd.call("procfile", str(tmp_path), dry_run=False, backup=False)
212212

213213
# Backup should not exist
214214
backup = tmp_path / "Procfile.bak"
@@ -279,7 +279,7 @@ def test_migrate_procfile_hop3_subdirectory(tmp_path):
279279
procfile_path.write_text("web: python app.py")
280280

281281
cmd = MigrateCmd()
282-
result = cmd.call("procfile", str(tmp_path), dry_run=False, backup=False)
282+
cmd.call("procfile", str(tmp_path), dry_run=False, backup=False)
283283

284284
# Should find and convert the Procfile in src/hop3/
285285
hop3_toml = hop3_dir / "hop3.toml"

packages/hop3-server/tests/a_unit/commands/test_config_set_unset.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ def test_config_set_multiple_variables(db_session: Session, test_app: App):
7474
def test_config_set_value_with_equals(db_session: Session, test_app: App):
7575
"""Test setting a variable with an equals sign in the value."""
7676
cmd = SetCmd(db_session=db_session)
77-
result = cmd.call(
78-
"testapp", "DATABASE_URL=postgres://user:pass@host/db?param=value"
79-
)
77+
cmd.call("testapp", "DATABASE_URL=postgres://user:pass@host/db?param=value")
8078

8179
# Verify it was saved with the full value including the equals sign
8280
app_repo = AppRepository(session=db_session)
@@ -88,7 +86,7 @@ def test_config_set_value_with_equals(db_session: Session, test_app: App):
8886
def test_config_set_empty_value(db_session: Session, test_app: App):
8987
"""Test setting a variable to an empty value."""
9088
cmd = SetCmd(db_session=db_session)
91-
result = cmd.call("testapp", "EMPTY_VAR=")
89+
cmd.call("testapp", "EMPTY_VAR=")
9290

9391
# Verify it was saved with empty string value
9492
app_repo = AppRepository(session=db_session)

packages/hop3-server/tests/a_unit/config/test_config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from pathlib import Path
77

8+
from hop3.config import HopConfig
89
from hop3.lib.config import Config
910

1011

@@ -20,8 +21,6 @@ def test_default(monkeypatch):
2021
Note: This test ensures HOP3_ROOT is set to the expected test default
2122
regardless of environment variables.
2223
"""
23-
from hop3.config import HopConfig # noqa: PLC0415
24-
2524
# Ensure HOP3_ROOT environment variable is set to test default
2625
monkeypatch.setenv("HOP3_ROOT", "/tmp/hop3")
2726

packages/hop3-server/tests/a_unit/plugins/docker/test_docker_deployer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ def test_deploy_success(self, tmp_path: Path, docker_artifact: BuildArtifact):
132132

133133
with (
134134
patch("subprocess.run") as mock_run,
135-
patch(
136-
"hop3.plugins.docker.deployer.get_free_port", return_value=9999
137-
) as mock_port,
135+
patch("hop3.plugins.docker.deployer.get_free_port", return_value=9999),
138136
):
139137
mock_run.return_value = MagicMock(returncode=0, stdout="", stderr="")
140138

packages/hop3-server/tests/b_integration/commands/test_services_commands_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def test_attach_with_custom_service_type(self, db_session: Session, test_app: Ap
407407

408408
cmd = AddonsAttachCmd(db_session=db_session)
409409

410-
result = cmd.call("my-cache", "--app", "test-app", "--type", "redis")
410+
cmd.call("my-cache", "--app", "test-app", "--type", "redis")
411411

412412
mock_get_addon.assert_called_once_with("redis", "my-cache")
413413

@@ -666,7 +666,7 @@ def test_detach_only_removes_specified_addon(
666666

667667
cmd = AddonsDetachCmd(db_session=db_session)
668668

669-
result = cmd.call("my-db", "--app", "test-app", "--type", "postgres")
669+
cmd.call("my-db", "--app", "test-app", "--type", "postgres")
670670

671671
db_session.expire_all()
672672

@@ -971,7 +971,7 @@ def test_info_with_default_service_type(self, db_session: Session):
971971

972972
cmd = AddonsInfoCmd(db_session=db_session)
973973

974-
result = cmd.call("default-db")
974+
cmd.call("default-db")
975975

976976
# Should default to postgres
977977
mock_get_addon.assert_called_once_with("postgres", "default-db")

packages/hop3-server/tests/b_integration/test_backup_commands.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def test_create_backup_includes_env_vars(self, test_db, test_app):
125125
"""Test that backup includes environment variables."""
126126
cmd = BackupCreateCmd(db_session=test_db)
127127

128-
result = cmd.call("test-app", "--no-addons")
128+
cmd.call("test-app", "--no-addons")
129129

130130
# Find the backup directory
131131
backup_dir = HopConfig.get_instance().BACKUP_ROOT / "apps" / "test-app"
@@ -146,7 +146,7 @@ def test_create_backup_includes_source(self, test_db, test_app):
146146
"""Test that backup includes source code."""
147147
cmd = BackupCreateCmd(db_session=test_db)
148148

149-
result = cmd.call("test-app", "--no-addons")
149+
cmd.call("test-app", "--no-addons")
150150

151151
# Find the backup directory
152152
backup_dir = HopConfig.get_instance().BACKUP_ROOT / "apps" / "test-app"
@@ -165,7 +165,7 @@ def test_create_backup_includes_data(self, test_db, test_app):
165165
"""Test that backup includes application data."""
166166
cmd = BackupCreateCmd(db_session=test_db)
167167

168-
result = cmd.call("test-app", "--no-addons")
168+
cmd.call("test-app", "--no-addons")
169169

170170
# Find the backup directory
171171
backup_dir = HopConfig.get_instance().BACKUP_ROOT / "apps" / "test-app"
@@ -184,7 +184,7 @@ def test_create_backup_generates_metadata(self, test_db, test_app):
184184
"""Test that backup generates correct metadata."""
185185
cmd = BackupCreateCmd(db_session=test_db)
186186

187-
result = cmd.call("test-app", "--no-addons")
187+
cmd.call("test-app", "--no-addons")
188188

189189
# Find the backup directory
190190
backup_dir = HopConfig.get_instance().BACKUP_ROOT / "apps" / "test-app"
@@ -292,7 +292,7 @@ def test_info_backup(self, test_db, test_app):
292292
"""Test getting backup info."""
293293
# Create a backup
294294
create_cmd = BackupCreateCmd(db_session=test_db)
295-
create_result = create_cmd.call("test-app", "--no-addons")
295+
create_cmd.call("test-app", "--no-addons")
296296

297297
# Extract backup ID from result
298298
backup_dir = HopConfig.get_instance().BACKUP_ROOT / "apps" / "test-app"

packages/hop3-server/tests/b_integration/test_dashboard_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def isolated_database(monkeypatch, worker_id):
6060
reset_session_factory_cache()
6161

6262
# Create the database schema
63-
session_factory = get_session_factory()
63+
get_session_factory()
6464

6565
yield db_uri
6666

0 commit comments

Comments
 (0)