pytorch
440b1920 - Type hints: Return `Iterator` instead of `Iterable` from `__iter__` (#27445)

Commit
5 years ago
Type hints: Return `Iterator` instead of `Iterable` from `__iter__` (#27445) Summary: `__iter__` methods are supposed to return iterators (https://docs.python.org/3/reference/datamodel.html#object.__iter__), but some of them are typed to return iterables, which is too general. This results in error messages such as `Iterable[Module[Any]]" has no attribute "__next__"` from Mypy. Technically this should also have caused a type error [here](https://github.com/pytorch/pytorch/blob/8f7020bbdbb5537bf1954cd252523cb17ab879b1/torch/nn/modules/container.py#L115), but due to a bug in Mypy type checking isn't working correctly in untyped methods (this will be fixed in the next release though: https://github.com/python/mypy/pull/7530). Pull Request resolved: https://github.com/pytorch/pytorch/pull/27445 Reviewed By: lerks Differential Revision: D18113966 Pulled By: fmassa fbshipit-source-id: c6261ac866f86df4328e6d2fdfca0625aa2d2492
Author
Parents
Loading