fix(lint): resolve all ruff lint errors

Add ruff config to exclude alembic E402, SQLAlchemy F821, and pre-existing
E501 line-length issues. Auto-fix 69 unused imports and 2 f-strings without
placeholders. Manually fix 8 unused variables. Apply ruff format to 127 files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jason Staack
2026-03-14 22:17:50 -05:00
parent 2ad0367c91
commit 06a41ca9bf
133 changed files with 2927 additions and 1890 deletions

View File

@@ -60,25 +60,32 @@ class TestPreviewRestoreFunction:
mock_scalar.scalar_one_or_none.return_value = mock_device
mock_db.execute.return_value = mock_scalar
with patch(
"app.routers.config_backups._check_tenant_access",
new_callable=AsyncMock,
), patch(
"app.routers.config_backups.limiter.enabled",
False,
), patch(
"app.routers.config_backups.git_store.read_file",
return_value=target_export.encode(),
), patch(
"app.routers.config_backups.backup_service.capture_export",
new_callable=AsyncMock,
return_value=current_export,
), patch(
"app.routers.config_backups.decrypt_credentials_hybrid",
new_callable=AsyncMock,
return_value='{"username": "admin", "password": "pass"}',
), patch(
"app.routers.config_backups.settings",
with (
patch(
"app.routers.config_backups._check_tenant_access",
new_callable=AsyncMock,
),
patch(
"app.routers.config_backups.limiter.enabled",
False,
),
patch(
"app.routers.config_backups.git_store.read_file",
return_value=target_export.encode(),
),
patch(
"app.routers.config_backups.backup_service.capture_export",
new_callable=AsyncMock,
return_value=current_export,
),
patch(
"app.routers.config_backups.decrypt_credentials_hybrid",
new_callable=AsyncMock,
return_value='{"username": "admin", "password": "pass"}',
),
patch(
"app.routers.config_backups.settings",
),
):
result = await preview_restore(
request=mock_request,
@@ -140,25 +147,32 @@ class TestPreviewRestoreFunction:
return current_export.encode()
return b""
with patch(
"app.routers.config_backups._check_tenant_access",
new_callable=AsyncMock,
), patch(
"app.routers.config_backups.limiter.enabled",
False,
), patch(
"app.routers.config_backups.git_store.read_file",
side_effect=mock_read_file,
), patch(
"app.routers.config_backups.backup_service.capture_export",
new_callable=AsyncMock,
side_effect=ConnectionError("Device unreachable"),
), patch(
"app.routers.config_backups.decrypt_credentials_hybrid",
new_callable=AsyncMock,
return_value='{"username": "admin", "password": "pass"}',
), patch(
"app.routers.config_backups.settings",
with (
patch(
"app.routers.config_backups._check_tenant_access",
new_callable=AsyncMock,
),
patch(
"app.routers.config_backups.limiter.enabled",
False,
),
patch(
"app.routers.config_backups.git_store.read_file",
side_effect=mock_read_file,
),
patch(
"app.routers.config_backups.backup_service.capture_export",
new_callable=AsyncMock,
side_effect=ConnectionError("Device unreachable"),
),
patch(
"app.routers.config_backups.decrypt_credentials_hybrid",
new_callable=AsyncMock,
return_value='{"username": "admin", "password": "pass"}',
),
patch(
"app.routers.config_backups.settings",
),
):
result = await preview_restore(
request=mock_request,
@@ -188,15 +202,19 @@ class TestPreviewRestoreFunction:
mock_request = MagicMock()
body = RestoreRequest(commit_sha="nonexistent")
with patch(
"app.routers.config_backups._check_tenant_access",
new_callable=AsyncMock,
), patch(
"app.routers.config_backups.limiter.enabled",
False,
), patch(
"app.routers.config_backups.git_store.read_file",
side_effect=KeyError("not found"),
with (
patch(
"app.routers.config_backups._check_tenant_access",
new_callable=AsyncMock,
),
patch(
"app.routers.config_backups.limiter.enabled",
False,
),
patch(
"app.routers.config_backups.git_store.read_file",
side_effect=KeyError("not found"),
),
):
with pytest.raises(HTTPException) as exc_info:
await preview_restore(