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]: ...
When using
mypyon the example code in the asynchronous notifications documentation, it doesn't consider iterators to have aclose()method:With the type changed to a
typing.Generator, thenmypyis happy with it.