Recently, Langgraph has v3 on stream_event and astream_event.
I tried using it, but I found it doesn’t have any type annotation - and things get worse when I try to annotate it with (Async)GraphRunStream, as it dynamically adds attributes like stream.messagesso that type checker never shows hint and even flags it as error.
So, my question is - is there any plan to add type annotation on those? v3 is still in beta phase, so I hope type annotation might got added one day…
So, I saw it had been updated to 1.2.10, and I updated - and still has an issue,
I copy-pasted this from document:
stream = graph.stream_events({
"messages": [{"role": "user", "content": "What is 42 * 17?"}],
}, version="v3")
for message in stream.messages:
for token in message.text:
print(token, end="", flush=True)
final_state = stream.output
And it yields typeerror at stream.messages.
I read the PR, and it says
Opt-in native projections (updates, custom, checkpoints, debug, tasks) are only present when their transformer is registered, so they remain reached via extensions[...] rather than annotated as always-present.
So how do I annotate those correctly? (I really want to get help from autocompletion and not disturbed by type checker)
Ah ok. I retested and am not seeing this issue with 1.2.10. Could you please check that the interpreter in whatever code editor you are using is configured properly?