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:
kitos
2026-06-10 12:37:15 +02:00
parent 9ff0f04ba3
commit d2a46feba8
158 changed files with 14861 additions and 248 deletions
+18
View File
@@ -1,25 +1,43 @@
"""ScoringConfig — single-row table for persisted scoring weights."""
# Import uuid
import uuid
# Import Column, DateTime, Float, ForeignKey, func from sqlalchemy
from sqlalchemy import Column, DateTime, Float, ForeignKey, func
# Import UUID from sqlalchemy.dialects.postgresql
from sqlalchemy.dialects.postgresql import UUID
# Import Base from app.database
from app.database import Base
# Define class ScoringConfig
class ScoringConfig(Base):
"""Single-row table persisting the active scoring weight configuration."""
# Assign __tablename__ = "scoring_config"
__tablename__ = "scoring_config"
# Assign id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
# Assign weight_tests = Column(Float, nullable=False, default=40.0)
weight_tests = Column(Float, nullable=False, default=40.0)
# Assign weight_detection_rules = Column(Float, nullable=False, default=25.0)
weight_detection_rules = Column(Float, nullable=False, default=25.0)
# Assign weight_d3fend = Column(Float, nullable=False, default=15.0)
weight_d3fend = Column(Float, nullable=False, default=15.0)
# Assign weight_recency = Column(Float, nullable=False, default=10.0)
weight_recency = Column(Float, nullable=False, default=10.0)
# Assign weight_severity = Column(Float, nullable=False, default=10.0)
weight_severity = Column(Float, nullable=False, default=10.0)
# Assign updated_by = Column(
updated_by = Column(
UUID(as_uuid=True),
ForeignKey("users.id", ondelete="SET NULL"),
# Keyword argument: nullable
nullable=True,
)
# Assign updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate...
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())