Coverage for backend/django/diagnostics/schemas.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2026-03-26 20:57 +0000

1""" 

2Shared Pydantic schemas for the diagnostics module. 

3 

4These models define the JSON finding shapes we return to the frontend. 

5Keeping them here avoids drifting "finding" definitions across: 

6- rules engine output (RuleFinding) 

7""" 

8 

9from __future__ import annotations 

10 

11from typing import Literal 

12 

13from pydantic import BaseModel, JsonValue 

14 

15# Severity levels expected by the frontend. 

16Severity = Literal["error", "warning", "info", "suggestion"] 

17 

18 

19class DiagnosticsFinding(BaseModel): 

20 """ 

21 A single diagnostics finding in the shape the UI expects. 

22 

23 Notes: 

24 - This is intentionally permissive: different finding sources attach different 

25  

26 """ 

27 

28 id: str | None = None 

29 severity: Severity = "info" 

30 title: str 

31 description: str 

32 ruleReference: str | None = None 

33 

34 componentName: str | None = None 

35 componentId: int | None = None 

36 propertyKey: str | None = None 

37 propertyId: int | None = None 

38 

39 suggestedFix: str | None = None 

40 suggestedValue: float | None = None 

41 fixAction: JsonValue | None = None 

42 

43 ignored: bool | None = None