chore(lint): apply ruff --fix (4443 auto-fixes)

Auto-fixed categories:
- F401: unused imports removed
- I001: import blocks sorted
- W293: trailing whitespace stripped
- UP035: deprecated typing imports replaced
- SIM: simplify suggestions applied
- ARG: unused args prefixed with underscore
- T201: print statements removed
- F841: unused variables removed
- RUF059: unpacked variables prefixed

Remaining ~1500 unfixable errors (C901, B904, N806, E402) require manual work.

Backend smoke tests: 13/13 passed.
This commit is contained in:
2026-05-14 11:20:17 +03:00
parent a9a5eff518
commit c6189876b3
337 changed files with 4677 additions and 4515 deletions

View File

@@ -5,21 +5,19 @@
"""Smoke tests for the redesigned clean release CLI commands."""
from datetime import UTC, datetime
from types import SimpleNamespace
import json
from src.dependencies import get_clean_release_repository, get_config_manager
from datetime import datetime, timezone
from uuid import uuid4
from src.dependencies import get_clean_release_repository, get_config_manager
from src.models.clean_release import (
CleanPolicySnapshot,
ComplianceReport,
ReleaseCandidate,
SourceRegistrySnapshot,
)
from src.services.clean_release.enums import CandidateStatus, ComplianceDecision
from src.scripts.clean_release_cli import main as cli_main
from src.services.clean_release.enums import CandidateStatus, ComplianceDecision
# [DEF:test_cli_candidate_register_scaffold:Function]
@@ -227,7 +225,7 @@ def test_cli_release_gate_commands_scaffold() -> None:
version="1.0.0",
source_snapshot_ref="git:sha-approved",
created_by="cli-test",
created_at=datetime.now(timezone.utc),
created_at=datetime.now(UTC),
status=CandidateStatus.CHECK_PASSED.value,
)
)
@@ -237,7 +235,7 @@ def test_cli_release_gate_commands_scaffold() -> None:
version="1.0.0",
source_snapshot_ref="git:sha-rejected",
created_by="cli-test",
created_at=datetime.now(timezone.utc),
created_at=datetime.now(UTC),
status=CandidateStatus.CHECK_PASSED.value,
)
)
@@ -252,7 +250,7 @@ def test_cli_release_gate_commands_scaffold() -> None:
"violations_count": 0,
"blocking_violations_count": 0,
},
generated_at=datetime.now(timezone.utc),
generated_at=datetime.now(UTC),
immutable=True,
)
)
@@ -267,7 +265,7 @@ def test_cli_release_gate_commands_scaffold() -> None:
"violations_count": 0,
"blocking_violations_count": 0,
},
generated_at=datetime.now(timezone.utc),
generated_at=datetime.now(UTC),
immutable=True,
)
)

View File

@@ -5,17 +5,16 @@
# @LAYER: Scripts
# @INVARIANT: TUI initializes, handles hotkeys (F5, F10) and safely falls back without TTY.
import os
import sys
import curses
import json
import os
from unittest import mock
from unittest.mock import MagicMock, patch
import pytest
from src.scripts.clean_release_tui import CleanReleaseTUI, main, tui_main
from src.models.clean_release import CheckFinalStatus
from src.scripts.clean_release_tui import CleanReleaseTUI, main
@pytest.fixture
@@ -63,17 +62,17 @@ def test_tui_initial_render(mock_curses_module, mock_stdscr: MagicMock):
app = CleanReleaseTUI(mock_stdscr)
assert app.status == "READY"
# We only want to run one loop iteration, so we mock getch to return F10
mock_stdscr.getch.return_value = curses.KEY_F10
app.loop()
# Assert header was drawn
addstr_calls = mock_stdscr.addstr.call_args_list
assert any("Enterprise Clean Release Validator" in str(call) for call in addstr_calls)
assert any("Candidate: [2026.03.03-rc1]" in str(call) for call in addstr_calls)
# Assert checks list is shown
assert any("Data Purity" in str(call) for call in addstr_calls)
assert any("Internal Sources Only" in str(call) for call in addstr_calls)
@@ -98,7 +97,7 @@ def test_tui_run_checks_f5(mock_curses_module, mock_stdscr: MagicMock):
mock_curses_module.A_BOLD = 0
app = CleanReleaseTUI(mock_stdscr)
# getch sequence:
# 1. First loop: F5 (triggers run_checks)
# 2. Next call after run_checks: F10 to exit
@@ -108,12 +107,12 @@ def test_tui_run_checks_f5(mock_curses_module, mock_stdscr: MagicMock):
mock_stdscr.f5_pressed = True
return curses.KEY_F5
return curses.KEY_F10
mock_stdscr.getch.side_effect = side_effect
with mock.patch("time.sleep", return_value=None):
app.loop()
# After F5 is pressed, status should be BLOCKED due to deliberate 'test-data' violation
assert app.status == CheckFinalStatus.BLOCKED
assert app.report_id is not None
@@ -132,13 +131,13 @@ def test_tui_exit_f10(mock_curses_module, mock_stdscr: MagicMock):
"""
# Ensure constants match
mock_curses_module.KEY_F10 = curses.KEY_F10
app = CleanReleaseTUI(mock_stdscr)
mock_stdscr.getch.return_value = curses.KEY_F10
# loop() should return cleanly
app.loop()
assert app.status == "READY"
@@ -159,12 +158,12 @@ def test_tui_clear_history_f7(mock_curses_module, mock_stdscr: MagicMock):
app = CleanReleaseTUI(mock_stdscr)
app.status = CheckFinalStatus.BLOCKED
app.report_id = "SOME-REPORT"
# F7 then F10
mock_stdscr.getch.side_effect = [curses.KEY_F7, curses.KEY_F10]
app.loop()
assert app.status == "READY"
assert app.report_id is None
assert len(app.checks_progress) == 0