more_itertools.consume argument iterator is annotated as Iterable[object], not Iterable[_T].
Because of that, mypy thinks all type variables inside iterator (like _T from itertools.takewhile) must be object, not allowing it's subclasses.
For a solution we should replace iterator: Iterator[object] with iterator: Iterator[_T]. This is enough to fix this case, but I didn't dig if it's OK for other cases, so your thoughts are welcome :)
Here is a bug demonstation:
# test.py
# more-itertools==10.0.0, mypy==1.4.1
import itertools
import more_itertools
more_itertools.consume(
itertools.takewhile(
lambda label: label.startswith("VB"),
["VBZ", "VBG", "VBN", "NP", "NN"],
),
)
mypy test.py
test.py:7: error: "object" has no attribute "startswith" [attr-defined]
Found 1 error in 1 file (checked 1 source file)