AsyncGenerator needs to include None in SendType?
#10828
Replies: 2 comments
|
Would this work for you? async def A():
gen = pure_int_generator()
await anext(gen) |
0 replies
|
Yeah that works, thanks! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hey all,
I'm running into an issue with type annotations for an AsyncGenerator. The issue is that the generator needs to be "primed" with sending
Noneonce. Otherwise this causes aTypeErrorat runtime. But this value will never appear in the Generator function. I would like to keep the function annotations without thatNone, otherwise I have to do None-checks all the time...Not sure if this is a "bug" or a "feature"? Is there an easy way around this? Feels kind of weird to be honest, like as if there should be
.start()method that does the priming.I.e. here's an example that should explain all of this (playground link).
All reactions