fix DictReader definition (#1475)

* constructable with Iterable
* __iter__ returns another DictReader
* supports `__next__` on python 3
* supports `next` on python 2
This commit is contained in:
Thomas Grainger
2017-07-11 05:02:59 +01:00
committed by Jelle Zijlstra
parent 45f2d9d625
commit 7637549ced

View File

@@ -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]