question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for type hints

See original GitHub issue

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()

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
graingertcommented, Sep 24, 2021

It would be more convenient if you merged them in and added a py.typed

0reactions
vbrauncommented, Apr 18, 2022

types-aiofiles is a nice first step but rather incomplete

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found