style: apply ruff formatting sweep

Co-authored-by: Copilot App <[email protected]>
This commit is contained in:
Jim Lancaster
2026-08-23 18:13:38 -05:00
co-authored by Copilot App
parent 4aaa9bd581
commit 2a56365847
37 changed files with 141 additions and 230 deletions
+1 -5
View File
@@ -154,11 +154,7 @@ class TestJobService:
finally:
event.remove(bind, "before_cursor_execute", capture)
claim_sql = [
item
for item in statements
if item.lstrip().upper().startswith(("SELECT", "UPDATE"))
]
claim_sql = [item for item in statements if item.lstrip().upper().startswith(("SELECT", "UPDATE"))]
assert len(claim_sql) == 1, claim_sql
assert "LIMIT" in claim_sql[0].upper()
assert "JOIN" not in claim_sql[0].upper()
+7 -4
View File
@@ -7,10 +7,13 @@ from transcription.db.models import Person
from transcription.services.people import PeopleService
from transcription.services.photos import PhotosService
PNG_BYTES = bytes.fromhex(
"89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c4890000000a49444154789c6360000002000100"
"05fe02fea7b1b8000000004945"
) + b"NDAE\xae\x42\x60\x82"
PNG_BYTES = (
bytes.fromhex(
"89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c4890000000a49444154789c6360000002000100"
"05fe02fea7b1b8000000004945"
)
+ b"NDAE\xae\x42\x60\x82"
)
@pytest.mark.asyncio
+1 -3
View File
@@ -35,9 +35,7 @@ def test_quality_analysis_accepts_clean_transcription():
@pytest.mark.unit
def test_quality_warning_payload_is_versioned():
payload = quality_warning_payload(
analyze_transcription_quality("[document body typeset]\nBroken \ufffd")
)
payload = quality_warning_payload(analyze_transcription_quality("[document body typeset]\nBroken \ufffd"))
assert payload["schema_name"] == "transcription.quality-warnings"
assert payload["schema_version"] == "1"
+1 -4
View File
@@ -73,10 +73,7 @@ async def test_create_job_for_document_sorts_sources_and_creates_links(async_ses
assert all(source.filename.endswith(".pdf") for source in sources)
assert all("A_page" not in source.filename and "b_page" not in source.filename for source in sources)
assert all(Path(source.filename).stem == str(source.id) for source in sources)
assert all(
source.file_path == f"documents/{document.id}/{source.filename}"
for source in sources
)
assert all(source.file_path == f"documents/{document.id}/{source.filename}" for source in sources)
assert [source.file_hash for source in sources] == [
"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb",
"3e23e8160039594a33894f6564e1b1348bbd7a0088d42c4acb73eeaed59c009d",
+2 -12
View File
@@ -43,13 +43,7 @@ pytestmark = [
def _real_image_paths() -> list[Path]:
if not REAL_IMAGES_DIR.exists():
return []
return sorted(
[
p
for p in REAL_IMAGES_DIR.iterdir()
if p.is_file() and p.suffix.lower() in SUPPORTED_EXTENSIONS
]
)
return sorted([p for p in REAL_IMAGES_DIR.iterdir() if p.is_file() and p.suffix.lower() in SUPPORTED_EXTENSIONS])
def _artifact_filename(image_path: Path) -> str:
@@ -78,11 +72,7 @@ class TestRealImageExternalTranscription:
ARTIFACTS_DIR.mkdir(parents=True, exist_ok=True)
artifact_path = ARTIFACTS_DIR / _artifact_filename(image_path)
artifact_text = (
f"source: {image_path.name}\n"
f"provider: {result.provider}\n"
f"model: {result.model}\n"
"---\n"
f"{result.text}\n"
f"source: {image_path.name}\nprovider: {result.provider}\nmodel: {result.model}\n---\n{result.text}\n"
)
artifact_path.write_text(artifact_text, encoding="utf-8")
assert artifact_path.exists()
+12 -21
View File
@@ -107,15 +107,12 @@ class TestWorkflowReliability:
async with services.jobs._session_scope() as session:
attempts = (
(
await session.exec(
select(ExecutionAttempt).where(
col(ExecutionAttempt.job_source_id).in_([js.id for js in result.job_sources])
)
await session.exec(
select(ExecutionAttempt).where(
col(ExecutionAttempt.job_source_id).in_([js.id for js in result.job_sources])
)
)
.all()
)
).all()
error_detail = next(attempt.error_detail for attempt in attempts if attempt.error_detail is not None)
assert "timed out" in error_detail.lower()
assert "20.0s" in error_detail
@@ -179,15 +176,12 @@ class TestWorkflowReliability:
async with services.jobs._session_scope() as session:
attempts = (
(
await session.exec(
select(ExecutionAttempt).where(
col(ExecutionAttempt.job_source_id).in_([js.id for js in result.job_sources])
)
await session.exec(
select(ExecutionAttempt).where(
col(ExecutionAttempt.job_source_id).in_([js.id for js in result.job_sources])
)
)
.all()
)
).all()
assert len(attempts) == 1
duration_ms = attempts[0].duration_ms
@@ -242,15 +236,12 @@ class TestWorkflowReliability:
async with services.jobs._session_scope() as session:
attempts = (
(
await session.exec(
select(ExecutionAttempt).where(
col(ExecutionAttempt.job_source_id).in_([js.id for js in result.job_sources])
)
await session.exec(
select(ExecutionAttempt).where(
col(ExecutionAttempt.job_source_id).in_([js.id for js in result.job_sources])
)
)
.all()
)
).all()
assert len(attempts) == 1
attempt = attempts[0]
timing = (attempt.normalized_metadata or {}).get("processing_timing")