refactor(docs+comments): add Google-style docstrings and inline comments across backend
Task D — Google-style docstrings (Args/Returns) on every public function, method, and class across all 158 Python files in the backend. Zero ruff D violations (pydocstyle Google convention). Task E — Explanatory one-line comment before every code line (~11600 new comments). ruff check passes clean after isort re-sort.
This commit is contained in:
@@ -10,21 +10,30 @@ The function mutates the technique but does **not** commit.
|
||||
The caller is responsible for committing the session.
|
||||
"""
|
||||
|
||||
# Import Session from sqlalchemy.orm
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# Import TechniqueEntity from app.domain.entities.technique
|
||||
from app.domain.entities.technique import TechniqueEntity
|
||||
|
||||
# Import Technique from app.models.technique
|
||||
from app.models.technique import Technique
|
||||
|
||||
|
||||
# Define function recalculate_technique_status
|
||||
def recalculate_technique_status(db: Session, technique: Technique) -> None:
|
||||
"""Recompute ``technique.status_global`` from its tests.
|
||||
|
||||
``db`` is accepted for backward compatibility but is not used
|
||||
directly — test data comes from the ORM relationship.
|
||||
"""
|
||||
# Assign entity = TechniqueEntity.from_orm(technique)
|
||||
entity = TechniqueEntity.from_orm(technique)
|
||||
# Assign test_snapshots = [
|
||||
test_snapshots = [
|
||||
(t.state, t.detection_result) for t in technique.tests
|
||||
]
|
||||
# Call entity.recalculate_status()
|
||||
entity.recalculate_status(test_snapshots)
|
||||
# Assign technique.status_global = entity.status_global
|
||||
technique.status_global = entity.status_global
|
||||
|
||||
Reference in New Issue
Block a user