Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy issue when iterating on a file line-by-line #105

Open
pietrodn opened this issue May 21, 2021 · 1 comment
Open

mypy issue when iterating on a file line-by-line #105

pietrodn opened this issue May 21, 2021 · 1 comment

Comments

@pietrodn
Copy link

mypy type checking fails on the following script:

import asyncio
from pathlib import Path

import aiofiles

FILENAME = Path.home() / ".zshrc"

async def main() -> None:
    async with aiofiles.open(FILENAME, "r") as input_fd:
        async for line in input_fd:
            print(line)

if __name__ == '__main__':
    asyncio.run(main())

The error:

$ mypy scratch.py

scratch.py:10: error: "Coroutine[Any, Any, Iterator[str]]" has no attribute "__anext__"
Found 1 error in 1 file (checked 1 source file)

I'm using mypy 0.812 (the latest version as of today) and Python 3.9.4.
The errors appears with the default mypy configuration.

@Akuli
Copy link

Akuli commented Jul 4, 2021

aiofiles doesn't have type hints. They are maintained separately at typeshed: https://github.com/python/typeshed/tree/master/stubs/aiofiles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants