Skip to content

aiofiles: looping over file doesn't work #5725

Closed

Description

@Akuli
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

Activity

  1. JelleZijlstra commented on Jul 9, 2021

    @JelleZijlstra
    Member

    I think #5724 fixed this, can you verify?

  2. Akuli commented on Jul 9, 2021

    @Akuli
    CollaboratorAuthor

    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
    
  3. added a commit that references this issue on Jul 9, 2021
    a2aaf1f
  4. added a commit that references this issue on Jul 11, 2021
    80591d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions