Coverage for britney2/excusedeps.py: 94%
30 statements
« prev ^ index » next coverage.py v6.5.0, created at 2025-03-23 07:34 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2025-03-23 07:34 +0000
1from typing import TYPE_CHECKING, Optional, Union
3from britney2.policies import PolicyVerdict
5if TYPE_CHECKING: 5 ↛ 6line 5 didn't jump to line 6, because the condition on line 5 was never true
6 from . import DependencyType, PackageId
9class DependencySpec(object):
10 def __init__(
11 self, deptype: "DependencyType", architecture: Optional[str] = None
12 ) -> None:
13 self.deptype = deptype
14 self.architecture = architecture
15 assert self.architecture != "all", "all not allowed for DependencySpec"
18class DependencyState(object):
19 dep: Optional[Union[str, "PackageId"]]
21 def __init__(self, dep: Union[str, "PackageId"]) -> None:
22 """State of a dependency
24 :param dep: the excuse that we are depending on
26 """
27 self.valid = True
28 self.verdict = PolicyVerdict.PASS
29 self.dep = dep
31 @property
32 def possible(self) -> bool:
33 return True
35 def invalidate(self, verdict: PolicyVerdict) -> None:
36 self.valid = False
37 self.verdict = PolicyVerdict.worst_of(verdict)
40class ImpossibleDependencyState(DependencyState):
41 """Object tracking an impossible dependency"""
43 def __init__(self, verdict: PolicyVerdict, desc: str) -> None:
44 """
46 :param desc: description of the impossible dependency
48 """
49 self.valid = False
50 self.verdict = verdict
51 self.desc = desc
52 self.dep = None
54 @property
55 def possible(self) -> bool:
56 return False