From 940b43ffeeb09dcafc0de749379175a69e9150d7 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 11 Jul 2017 00:24:07 +0100 Subject: [PATCH] fix DictReader definition * constructable with Iterable * __iter__ returns another DictReader * supports `__next__` on python 3 * supports `next` on python 2 --- stdlib/2and3/csv.pyi | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/stdlib/2and3/csv.pyi b/stdlib/2and3/csv.pyi index a61edcb411ac..9774f518b086 100644 --- a/stdlib/2and3/csv.pyi +++ b/stdlib/2and3/csv.pyi @@ -59,11 +59,11 @@ if sys.version_info >= (3, 6): dialect = ... # type: _Dialect line_num = ... # type: int fieldnames = ... # type: Sequence[str] - def __init__(self, f: Iterator[str], fieldnames: Sequence[str] = ..., + def __init__(self, f: Iterable[str], fieldnames: Sequence[str] = ..., restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ..., *args: Any, **kwds: Any) -> None: ... - def __iter__(self) -> Iterator[OrderedDict[str, str]]: ... - def next(self) -> OrderedDict[str, str]: ... + def __iter__(self) -> 'DictReader': ... + def __next__(self) -> OrderedDict[str, str]: ... else: class DictReader(Iterator[Dict[Any, str]]): restkey = ... # type: Optional[str] @@ -72,11 +72,14 @@ else: dialect = ... # type: _Dialect line_num = ... # type: int fieldnames = ... # type: Sequence[str] - def __init__(self, f: Iterator[str], fieldnames: Sequence[str] = ..., + def __init__(self, f: Iterable[str], fieldnames: Sequence[str] = ..., restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ..., *args: Any, **kwds: Any) -> None: ... - def __iter__(self) -> Iterator[OrderedDict[Any, str]]: ... - def next(self) -> OrderedDict[Any, str]: ... + def __iter__(self) -> 'DictReader': ... + if sys.version_info >= (3,): + def __next__(self) -> OrderedDict[Any, str]: ... + else: + def next(self) -> OrderedDict[Any, str]: ... class DictWriter(object): fieldnames = ... # type: Sequence[str]