mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Make fieldnames of csv.DictReader Optional (#3534)
Also run stdlib/2and3/csv.pyi through black and isort
This commit is contained in:
committed by
Sebastian Rittau
parent
9b63192390
commit
a06abc5dff
@@ -1,23 +1,23 @@
|
||||
from collections import OrderedDict
|
||||
import sys
|
||||
from _csv import (
|
||||
QUOTE_ALL as QUOTE_ALL,
|
||||
QUOTE_MINIMAL as QUOTE_MINIMAL,
|
||||
QUOTE_NONE as QUOTE_NONE,
|
||||
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
|
||||
Error as Error,
|
||||
_reader,
|
||||
_writer,
|
||||
field_size_limit as field_size_limit,
|
||||
get_dialect as get_dialect,
|
||||
list_dialects as list_dialects,
|
||||
reader as reader,
|
||||
register_dialect as register_dialect,
|
||||
unregister_dialect as unregister_dialect,
|
||||
writer as writer,
|
||||
)
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, Union
|
||||
|
||||
from _csv import (_reader,
|
||||
_writer,
|
||||
reader as reader,
|
||||
writer as writer,
|
||||
register_dialect as register_dialect,
|
||||
unregister_dialect as unregister_dialect,
|
||||
get_dialect as get_dialect,
|
||||
list_dialects as list_dialects,
|
||||
field_size_limit as field_size_limit,
|
||||
QUOTE_ALL as QUOTE_ALL,
|
||||
QUOTE_MINIMAL as QUOTE_MINIMAL,
|
||||
QUOTE_NONE as QUOTE_NONE,
|
||||
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
|
||||
Error as Error,
|
||||
)
|
||||
|
||||
_Dialect = Union[str, Dialect, Type[Dialect]]
|
||||
_DictRow = Mapping[str, Any]
|
||||
|
||||
@@ -56,7 +56,6 @@ if sys.version_info >= (3, 6):
|
||||
else:
|
||||
_DRMapping = Dict[str, str]
|
||||
|
||||
|
||||
class DictReader(Iterator[_DRMapping]):
|
||||
restkey: Optional[str]
|
||||
restval: Optional[str]
|
||||
@@ -64,24 +63,37 @@ class DictReader(Iterator[_DRMapping]):
|
||||
dialect: _Dialect
|
||||
line_num: int
|
||||
fieldnames: Sequence[str]
|
||||
def __init__(self, f: Iterable[Text], fieldnames: Sequence[str] = ...,
|
||||
restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ...,
|
||||
*args: Any, **kwds: Any) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
f: Iterable[Text],
|
||||
fieldnames: Optional[Sequence[str]] = ...,
|
||||
restkey: Optional[str] = ...,
|
||||
restval: Optional[str] = ...,
|
||||
dialect: _Dialect = ...,
|
||||
*args: Any,
|
||||
**kwds: Any,
|
||||
) -> None: ...
|
||||
def __iter__(self) -> DictReader: ...
|
||||
if sys.version_info >= (3,):
|
||||
def __next__(self) -> _DRMapping: ...
|
||||
else:
|
||||
def next(self) -> _DRMapping: ...
|
||||
|
||||
|
||||
class DictWriter(object):
|
||||
fieldnames: Sequence[str]
|
||||
restval: Optional[Any]
|
||||
extrasaction: str
|
||||
writer: _writer
|
||||
def __init__(self, f: Any, fieldnames: Iterable[str],
|
||||
restval: Optional[Any] = ..., extrasaction: str = ..., dialect: _Dialect = ...,
|
||||
*args: Any, **kwds: Any) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
f: Any,
|
||||
fieldnames: Iterable[str],
|
||||
restval: Optional[Any] = ...,
|
||||
extrasaction: str = ...,
|
||||
dialect: _Dialect = ...,
|
||||
*args: Any,
|
||||
**kwds: Any,
|
||||
) -> None: ...
|
||||
def writeheader(self) -> None: ...
|
||||
def writerow(self, rowdict: _DictRow) -> None: ...
|
||||
def writerows(self, rowdicts: Iterable[_DictRow]) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user