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

aiofiles: looping over file doesn't work #5725

Closed
Akuli opened this issue Jul 4, 2021 · 2 comments · Fixed by #5750
Closed

aiofiles: looping over file doesn't work #5725

Akuli opened this issue Jul 4, 2021 · 2 comments · Fixed by #5750

Comments

@Akuli
Copy link
Collaborator

Akuli commented Jul 4, 2021

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())
scratch.py:10: error: "Coroutine[Any, Any, Iterator[str]]" has no attribute "__anext__"
Found 1 error in 1 file (checked 1 source file)

Originally reported at Tinche/aiofiles#105

@JelleZijlstra
Copy link
Member

I think #5724 fixed this, can you verify?

@Akuli
Copy link
Collaborator Author

Akuli commented Jul 9, 2021

Still happens:

(e39) akuli@akuli-desktop:/tmp$ mypy a.py
a.py:10: error: "Coroutine[Any, Any, Any]" has no attribute "__anext__"
Found 1 error in 1 file (checked 1 source file)
(e39) akuli@akuli-desktop:/tmp$ pip freeze
mypy==0.910
mypy-extensions==0.4.3
toml==0.10.2
types-aiofiles==0.1.6
typing-extensions==3.10.0.0
(e39) akuli@akuli-desktop:/tmp$ python3 --version
Python 3.9.1

JelleZijlstra added a commit that referenced this issue Jul 9, 2021
Fixes #5725.

This doesn't actually work properly in mypy; I'll report a bug for that.
Akuli pushed a commit that referenced this issue Jul 11, 2021
Fixes #5725.

This doesn't actually work properly in mypy.
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

Successfully merging a pull request may close this issue.

2 participants