Support for type hints
It'd be really nice to be able to use mypy against files that include aiofiles, but that's not possible now since aiofiles isn't typed.
A simple example shows that mypy --strict doesn't allow use of aiofiles.open:
$ mypy --strict main.py
main.py:13: error: Call to untyped function "open" in typed context
Here's the code:
#!/usr/bin/env python
import aiofiles
import asyncio
def main() -> None:
el = asyncio.get_event_loop()
el.run_until_complete(async_main())
async def async_main() -> None:
async with aiofiles.open('test_aiofiles', 'wb') as f:
await f.write(b'Hello, world!\n')
if __name__ == '__main__':
main()
Feel like submitting a pull request? You'd need to use the old typing style (e.g. in comments) but it shouldn't be too difficult.
@Tinche Python has supported function annotations since https://www.python.org/dev/peps/pep-3107/
As long as the tests pass on our current platforms, I'll merge it in :)
Mitigations addressed in the Debian bug report:
https://bugs.debian.org/994932
Hm looks like someone wrote stubs for us?
pip install types-aiofiles
Would this be enough to close this issue?
It would be more convenient if you merged them in and added a py.typed
Yes, that is enough.
types-aiofiles is a nice first step but rather incomplete
bump