Skip to content

Commit 0bb530f

Browse files
committed
fix: pr comments
1 parent 852578a commit 0bb530f

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

mellea/core/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,10 @@ def __init__(self, thunk: ModelOutputThunk[S]) -> None:
585585
Uses zero-copy class reassignment: calling `ComputedModelOutputThunk(thunk)` reassigns
586586
the thunk's `__class__` to `ComputedModelOutputThunk` without creating a new object.
587587
"""
588-
if not self.is_computed():
588+
# Call the underlying value. It's already been cast as a ComputedModelOutputThunk, so it's .is_computed() value is always True.
589+
if not self._computed:
589590
raise ValueError(
590-
"ComputedModelOutputThunk requires a computed ModelOutputThunk; but .is_computed() is False."
591+
"ComputedModelOutputThunk requires a computed ModelOutputThunk; but ._computed is False."
591592
)
592593
if self.value is None:
593594
raise ValueError("ComputedModelOutputThunk requires a non-None value.")
@@ -600,7 +601,7 @@ async def avalue(self) -> str:
600601
async def astream(self) -> str:
601602
"""Cannot astream from ComputedModelOutputThunks. Use .value() instead."""
602603
raise RuntimeError(
603-
"Cannot stream from a ComputedModelOutputThunk."
604+
"Cannot stream from a ComputedModelOutputThunk. "
604605
"This thunk is already fully computed and does not support streaming."
605606
)
606607

test/core/test_computed_model_output_thunk.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ def test_computed_thunk_requires_computed_thunk():
2222
"""Test that ComputedModelOutputThunk requires a computed ModelOutputThunk."""
2323
uncomputed_thunk = ModelOutputThunk(value=None)
2424

25+
assert not uncomputed_thunk._computed, (
26+
"thunk should be uncomputed when passed a None value"
27+
)
28+
2529
with pytest.raises(
26-
ValueError, match="ComputedModelOutputThunk requires a non-None value"
30+
ValueError,
31+
match="ComputedModelOutputThunk requires a computed ModelOutputThunk;",
2732
):
2833
ComputedModelOutputThunk(uncomputed_thunk)
2934

0 commit comments

Comments
 (0)