Skip to content

Connection.notifies() should have a generator type hint #128

@richli

Description

@richli

When using mypy on the example code in the asynchronous notifications documentation, it doesn't consider iterators to have a close() method:

$ mypy --pretty test.py
test.py:8: error: "Iterator[Notify]" has no attribute "close"
            gen.close()
            ^
Found 1 error in 1 file (checked 1 source file)

With the type changed to a typing.Generator, then mypy is happy with it.

def notifies(self) -> Generator[Notify, None, None]: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions