C1a: code only, no comments, no Markdown

Remove 64 Python docstrings and 39 comments, and trim prose from three noqa pragmas. The submodule had zero tracked Markdown files.

Move published route descriptions into decorator arguments and the Correction schema description into ConfigDict. Drop internal docstrings, including the OAuth callback excluded from OpenAPI. Published route descriptions are unchanged in the before-and-after comparison of the nine application routers. The full application OpenAPI check requires fastapi-users, which is missing from the shared environment.
This commit is contained in:
2026-12-01 16:55:32 -06:00
parent 37c456c5ef
commit c326f4901d
13 changed files with 284 additions and 207 deletions
+56 -23
View File
@@ -1,9 +1,7 @@
"""What waits for a person, and their decisions (append-only; the next run applies them)."""
from typing import Any
from fastapi import APIRouter, Depends
from pydantic import BaseModel, model_validator
from pydantic import BaseModel, ConfigDict, model_validator
from core.pipeline import EntityName, Id, validate
from core.schema import ENTITIES
@@ -14,29 +12,44 @@ router = APIRouter(prefix="/review", tags=["review"])
Rows = list[dict[str, Any]]
@router.get("/held")
@router.get(
"/held",
description="Rows a rule held, with the reasons and the values as they came.",
)
def held(entity: EntityName) -> Rows:
"""Rows a rule held, with the reasons and the values as they came."""
return review.held(entity)
@router.get("/conflicts")
@router.get(
"/conflicts",
description="Rows of one person and date that disagree; reject the wrong ones.",
)
def conflicts(entity: EntityName) -> Rows:
"""Rows of one person and date that disagree; reject the wrong ones."""
return review.conflicts(entity)
@router.get("/unrecognised")
@router.get(
"/unrecognised",
description=(
"Documents a pipeline's routes don't recognise (what its "
"`otherwise` routes took):\n"
"a new layout, a study the platform doesn't know, a scan nothing "
"could read."
),
)
def unrecognised(pipeline: Id) -> Rows:
"""Documents a pipeline's routes don't recognise (what its `otherwise` routes took):
a new layout, a study the platform doesn't know, a scan nothing could read."""
return review.unrecognised(pipeline)
@router.get("/persons")
@router.get(
"/persons",
description=(
"Persons to settle (with their possible owners), torn persons "
"and persons nothing\n"
"names (with their records) left by a pipeline's link node."
),
)
def persons(pipeline: Id, node: Id) -> dict[str, Rows]:
"""Persons to settle (with their possible owners), torn persons and persons nothing
names (with their records) left by a pipeline's link node."""
return review.persons(pipeline, node)
@@ -46,16 +59,27 @@ class PersonDecision(BaseModel):
same: bool
@router.post("/persons", status_code=201)
@router.post(
"/persons",
status_code=201,
description="Whether a person and a possible owner are one patient; applied on the next run.",
)
def decide_persons(decision: PersonDecision, who: Caller = Depends(caller)) -> dict[str, str]:
"""Whether a person and a possible owner are one patient; applied on the next run."""
nodes.decide_persons(decision.person, decision.candidate, decision.same, who.id)
return {"person": decision.person}
class Correction(BaseModel):
"""One field of one record as a reviewer read it in the source document: an identity
field (a mistyped record number) or a study's (a stage the scan made unreadable)."""
model_config = ConfigDict(
json_schema_extra={
"description": (
"One field of one record as a reviewer read it in the source "
"document: an identity\n"
"field (a mistyped record number) or a study's (a stage the scan "
"made unreadable)."
)
}
)
entity: EntityName = "identity"
record: str
@@ -66,7 +90,6 @@ class Correction(BaseModel):
def _a_valid_value(self):
if self.field not in ENTITIES[self.entity].model_fields:
raise ValueError(f"{self.entity} has no field {self.field}")
# only this field's own problems (a study's other required fields aren't given here)
reasons = [r for r in validate(self.entity, {self.field: self.value})
if r.split(":")[0] == self.field] # fmt: skip
if reasons:
@@ -74,10 +97,17 @@ class Correction(BaseModel):
return self
@router.post("/corrections", status_code=201)
@router.post(
"/corrections",
status_code=201,
description=(
"A corrected field of one record; the next run uses it (linking "
"for identity fields,\n"
"the study's target for the others). Fixing the source too is "
"still worth it."
),
)
def correct(fix: Correction, who: Caller = Depends(caller)) -> dict[str, str]:
"""A corrected field of one record; the next run uses it (linking for identity fields,
the study's target for the others). Fixing the source too is still worth it."""
nodes.correct(fix.record, fix.field, fix.value, who.id, fix.entity)
return {"record": fix.record}
@@ -88,8 +118,11 @@ class Rejection(BaseModel):
reason: str
@router.post("/rejections", status_code=201)
@router.post(
"/rejections",
status_code=201,
description="This record's row must not reach silver; applied on the next run.",
)
def reject(decision: Rejection, who: Caller = Depends(caller)) -> dict[str, str]:
"""This record's row must not reach silver; applied on the next run."""
nodes.reject(decision.entity, decision.record, decision.reason, who.id)
return {"record": decision.record}