1616
1717import os
1818import time
19+ from collections .abc import Generator
1920from datetime import timedelta
21+ from typing import Any
2022
2123from opentelemetry import trace
2224from opentelemetry .exporter .otlp .proto .grpc .trace_exporter import OTLPSpanExporter
@@ -64,7 +66,7 @@ def get_weather(ctx: task.ActivityContext, city: str) -> str:
6466 return result
6567
6668
67- def summarize (ctx : task .ActivityContext , reports : list ) -> str :
69+ def summarize (ctx : task .ActivityContext , reports : list [ str ] ) -> str :
6870 """Combine individual weather reports into a summary string."""
6971 summary = " | " .join (reports )
7072 print (f" [Activity] summarize -> { summary } " )
@@ -75,9 +77,9 @@ def summarize(ctx: task.ActivityContext, reports: list) -> str:
7577# Sub-orchestration
7678# ---------------------------------------------------------------------------
7779
78- def collect_weather (ctx : task .OrchestrationContext , cities : list ) :
80+ def collect_weather (ctx : task .OrchestrationContext , cities : list [ str ]) -> Generator [ task . Task [ Any ], Any , list [ str ]] :
7981 """Sub-orchestration that collects weather for a list of cities."""
80- results = []
82+ results : list [ str ] = []
8183 for city in cities :
8284 weather = yield ctx .call_activity (get_weather , input = city )
8385 results .append (f"{ city } : { weather } " )
@@ -88,7 +90,7 @@ def collect_weather(ctx: task.OrchestrationContext, cities: list):
8890# Main orchestration
8991# ---------------------------------------------------------------------------
9092
91- def weather_report_orchestrator (ctx : task .OrchestrationContext , cities : list ) :
93+ def weather_report_orchestrator (ctx : task .OrchestrationContext , cities : list [ str ]) -> Generator [ task . Task [ Any ], Any , str ] :
9294 """Top-level orchestration demonstrating timers, activities, and sub-orchestrations.
9395
9496 Flow:
0 commit comments