Support for type hints
See original GitHub issueIt’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()
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (7 by maintainers)
Top Results From Across the Web
typing — Support for type hints — Python 3.11.1 documentation
This module provides runtime support for type hints. The most fundamental support consists of the types Any , Union , Callable , TypeVar...
Read more >Type Hinting - Real Python
In this lesson, you'll learn about type hinting in Python. Type hinting is a formal solution to statically indicate the type of a...
Read more >What are type hints in Python 3.5? - Stack Overflow
With TypeHints, Python supports type annotation for the basic variable types supported by the language str, int, float, bool and None. It also ......
Read more >Type hints cheat sheet - mypy 0.991 documentation
Type hints cheat sheet#. This document is a quick cheat sheet showing how to use type annotations for various common types in Python....
Read more >12 Beginner Concepts About Type Hints To Improve Your ...
1— Type annotations: a new syntax to support adding types. Type hints are performed using Python annotations (introduced since PEP 3107).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It would be more convenient if you merged them in and added a py.typed
types-aiofiles is a nice first step but rather incomplete