Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/pyrecest/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ class EvidenceSupport:
diagnostics: dict[str, Any] = field(default_factory=dict)

def __post_init__(self) -> None:
if self.support_type not in _EVIDENCE_SUPPORT_TYPES:
if (
not isinstance(self.support_type, str)
or self.support_type not in _EVIDENCE_SUPPORT_TYPES
):
raise ValueError(
f"unsupported evidence support type {self.support_type!r}; "
f"expected one of {sorted(_EVIDENCE_SUPPORT_TYPES)}"
Expand Down
10 changes: 10 additions & 0 deletions tests/test_evidence_support_invalid_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pytest

from pyrecest.diagnostics import EvidenceSupport


def test_evidence_support_rejects_list_value() -> None:
bad_value = list(("unknown",))

with pytest.raises(ValueError, match="unsupported evidence support type"):
EvidenceSupport(bad_value)
Loading