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

18 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2026-06-23 21:51 +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 

14from diagnostics.models.DiagnosticsResult import Severity 

15 

16 

17 

18class DiagnosticsFinding(BaseModel): 

19 """ 

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

21 

22 Notes: 

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

24  

25 """ 

26 

27 id: str | None = None 

28 severity: Severity = "info" 

29 title: str 

30 description: str 

31 ruleReference: str | None = None 

32 

33 componentName: str | None = None 

34 componentId: int | None = None 

35 propertyKey: str | None = None 

36 propertyId: int | None = None 

37 

38 suggestedFix: str | None = None 

39 suggestedValue: float | None = None 

40 fixAction: JsonValue | None = None 

41 

42 ignored: bool | None = None