mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
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:
committed by
Jelle Zijlstra
parent
de86f15fa0
commit
c4ee2ed36a
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user