From 70e7d8d06912d3246444bb53cbda833b241316c6 Mon Sep 17 00:00:00 2001 From: unikcc <19505579+unikcc@users.noreply.github.com> Date: Sun, 5 Apr 2026 02:25:44 +0800 Subject: [PATCH] fix: guard against None comparison in quick_start.py example total_cost_usd defaults to None, causing TypeError on None > 0. Added truthiness check before comparison, consistent with other example files like agents.py. --- examples/quick_start.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/quick_start.py b/examples/quick_start.py index 3f128552..9fa32154 100644 --- a/examples/quick_start.py +++ b/examples/quick_start.py @@ -60,7 +60,11 @@ async def with_tools_example(): for block in message.content: if isinstance(block, TextBlock): print(f"Claude: {block.text}") - elif isinstance(message, ResultMessage) and message.total_cost_usd > 0: + elif ( + isinstance(message, ResultMessage) + and message.total_cost_usd + and message.total_cost_usd > 0 + ): print(f"\nCost: ${message.total_cost_usd:.4f}") print()