From c4ee2ed36a73104b8a1413a0c698aa8084eff912 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 12 Jun 2018 15:45:11 -0700 Subject: [PATCH] Correct annotation for `fileinput.input` (#2223) ```python import fileinput with fileinput.input(files=('foo.txt',), inplace=True, backup='') as f: for line in f: print(f'prefix{line}', end='') ``` ``` $ mypy test2.py test2.py:3: error: "Iterable[str]" has no attribute "__enter__"; maybe "__iter__"? test2.py:3: error: "Iterable[str]" has no attribute "__exit__" ``` ``` $ mypy test2.py --custom-typeshed typeshed $ ``` --- stdlib/2and3/fileinput.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2and3/fileinput.pyi b/stdlib/2and3/fileinput.pyi index 8a56ecaf6..0eb8ca9d8 100644 --- a/stdlib/2and3/fileinput.pyi +++ b/stdlib/2and3/fileinput.pyi @@ -15,7 +15,7 @@ def input( backup: str = ..., bufsize: int = ..., mode: str = ..., - openhook: Callable[[_Path, str], IO[AnyStr]] = ...) -> Iterable[AnyStr]: ... + openhook: Callable[[_Path, str], IO[AnyStr]] = ...) -> FileInput[AnyStr]: ... def close() -> None: ...