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
$
```
This commit is contained in:
Anthony Sottile
2018-06-12 15:45:11 -07:00
committed by Jelle Zijlstra
parent de86f15fa0
commit c4ee2ed36a

View File

@@ -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: ...