# HG changeset patch # User Matt Harbison # Date 2023-01-06 00:42:45 # Node ID ffeeaeb2d142586228c281926a620373efabf70c # Parent d5116e4dc74459d81471ce046c480ac34d93f06b typing: adjust `mercurial.util.iterlines()` to accept any `Iterable` In a local pytype run on the extensions, this fixes: File "/mnt/c/Users/Matt/hg/hgext/phabricator.py", line 788, in maketext: Function mercurial.util.iterlines was called with the wrong arguments [wrong-arg-types] Expected: (iterator: Iterator[bytes]) Actually passed: (iterator: list) Attributes of protocol Iterator[bytes] are not implemented on list: __next__ diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -60,6 +60,7 @@ from .utils import ( if pycompat.TYPE_CHECKING: from typing import ( + Iterable, Iterator, List, Optional, @@ -2910,7 +2911,7 @@ def iterfile(fp): def iterlines(iterator): - # type: (Iterator[bytes]) -> Iterator[bytes] + # type: (Iterable[bytes]) -> Iterator[bytes] for chunk in iterator: for line in chunk.splitlines(): yield line