Code:
from typing import AsyncIterable
import asyncio
async def agen() -> AsyncIterable[str]:
print('agen start')
yield '1'
yield '2'
async def agenmaker() -> AsyncIterable[str]:
print('agenmaker start')
return agen()
async def amain():
print('amain')
async for item in agen():
pass
async for item in await agenmaker():
pass
# Error:
async for item in agenmaker():
pass
def main():
asyncio.get_event_loop().run_until_complete(amain())
if __name__ == '__main__':
main()
As you can see, it is type-annotated, and contains an easy-to-miss error.
However, neither pylint nor mypy find that error.
Aside from unit tests, what options are there for catching such errors?