Skip to content

Commit 75d4e1a

Browse files
graingertGuido van Rossum
authored and
Guido van Rossum
committed
fix DictReader definition (#1475)
* constructable with Iterable * __iter__ returns another DictReader * supports `__next__` on python 3 * supports `next` on python 2
1 parent 0e26c1f commit 75d4e1a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

stdlib/2and3/csv.pyi

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ if sys.version_info >= (3, 6):
5959
dialect = ... # type: _Dialect
6060
line_num = ... # type: int
6161
fieldnames = ... # type: Sequence[str]
62-
def __init__(self, f: Iterator[str], fieldnames: Sequence[str] = ...,
62+
def __init__(self, f: Iterable[str], fieldnames: Sequence[str] = ...,
6363
restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ...,
6464
*args: Any, **kwds: Any) -> None: ...
65-
def __iter__(self) -> Iterator[OrderedDict[str, str]]: ...
66-
def next(self) -> OrderedDict[str, str]: ...
65+
def __iter__(self) -> 'DictReader': ...
66+
def __next__(self) -> OrderedDict[str, str]: ...
6767
else:
6868
class DictReader(Iterator[Dict[Any, str]]):
6969
restkey = ... # type: Optional[str]
@@ -72,11 +72,14 @@ else:
7272
dialect = ... # type: _Dialect
7373
line_num = ... # type: int
7474
fieldnames = ... # type: Sequence[str]
75-
def __init__(self, f: Iterator[str], fieldnames: Sequence[str] = ...,
75+
def __init__(self, f: Iterable[str], fieldnames: Sequence[str] = ...,
7676
restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ...,
7777
*args: Any, **kwds: Any) -> None: ...
78-
def __iter__(self) -> Iterator[OrderedDict[Any, str]]: ...
79-
def next(self) -> OrderedDict[Any, str]: ...
78+
def __iter__(self) -> 'DictReader': ...
79+
if sys.version_info >= (3,):
80+
def __next__(self) -> OrderedDict[Any, str]: ...
81+
else:
82+
def next(self) -> OrderedDict[Any, str]: ...
8083

8184
class DictWriter(object):
8285
fieldnames = ... # type: Sequence[str]

0 commit comments

Comments
 (0)