Coverage for functions \ flipdare \ generated \ shared \ risk \ risk_score.py: 100%
0 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
1#!/usr/bin/env python
2#
3# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
4#
5# This file is part of Flipdare's proprietary software and contains
6# confidential and copyrighted material. Unauthorised copying,
7# modification, distribution, or use of this file is strictly
8# prohibited without prior written permission from Flipdare Pty Ltd.
9#
10# This software includes third-party components licensed under MIT,
11# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
12#
13# NOTE: THIS FILE IS AUTO GENERATED. DO NOT EDIT.
14#
15# Generated by codegen_models.py
16#
17# Modify 'codegen_models.py'
18# and re-run the script above to update.
19#
21# pragma: no cover
23from enum import StrEnum
26class RiskScore(StrEnum):
27 """Risk release delay categories."""
29 # Declared here so type-checkers know these attributes exist.
30 # They are populated per-member inside __new__.
31 _days: int
33 def __new__(
34 cls,
35 code: str,
36 days: int | None = None,
37 ) -> "RiskScore":
38 obj = str.__new__(cls, code)
39 obj._value_ = code
40 # Only set attributes if they are provided (during member definition)
41 if days is not None:
42 obj._days = days
43 return obj
45 # ---- Members --------------------------------------------------------
46 # fmt: off
47 HIGH = ("high", 14)
48 MEDIUM = ("medium", 7)
49 MEDIUM_LOW = ("medium_low", 3)
50 LOW = ("low", 2)
51 # fmt: on
52 # ---- Properties -----------------------------------------------------
53 @property
54 def days(self) -> int:
55 return self._days
57 # ---- Convenience predicates -----------------------------------------
59 @classmethod
60 def from_score(cls, score: float) -> "RiskScore":
61 from flipdare.constants import HIGH_RISK_SCORE, MEDIUM_LOW_RISK_SCORE, MEDIUM_RISK_SCORE
63 if score >= HIGH_RISK_SCORE:
64 return RiskScore.HIGH
65 elif score >= MEDIUM_RISK_SCORE:
66 return RiskScore.MEDIUM
67 elif score >= MEDIUM_LOW_RISK_SCORE:
68 return RiskScore.MEDIUM_LOW
69 else:
70 return RiskScore.LOW