Skip to content

Commit 1c84982

Browse files
ymyzkmatthiaskramm
authored andcommitted
Update stub for csv (#1398)
1 parent 5d1aacf commit 1c84982

File tree

4 files changed

+118
-157
lines changed

4 files changed

+118
-157
lines changed

stdlib/2/csv.pyi

Lines changed: 0 additions & 84 deletions
This file was deleted.

stdlib/2and3/_csv.pyi

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import sys
2+
3+
from typing import Any, Iterable, Iterator, List, Optional, Sequence
4+
5+
QUOTE_ALL = ... # type: int
6+
QUOTE_MINIMAL = ... # type: int
7+
QUOTE_NONE = ... # type: int
8+
QUOTE_NONNUMERIC = ... # type: int
9+
10+
class Error(Exception): ...
11+
12+
class Dialect:
13+
delimiter = ... # type: str
14+
quotechar = ... # type: Optional[str]
15+
escapechar = ... # type: Optional[str]
16+
doublequote = ... # type: bool
17+
skipinitialspace = ... # type: bool
18+
lineterminator = ... # type: str
19+
quoting = ... # type: int
20+
strict = ... # type: int
21+
def __init__(self) -> None: ...
22+
23+
class _reader(Iterator[List[str]]):
24+
dialect = ... # type: Dialect
25+
line_num = ... # type: int
26+
27+
class _writer:
28+
dialect = ... # type: Dialect
29+
30+
if sys.version_info >= (3, 5):
31+
def writerow(self, row: Iterable[Any]) -> None: ...
32+
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
33+
else:
34+
def writerow(self, row: Sequence[Any]) -> None: ...
35+
def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ...
36+
37+
38+
# TODO: precise type
39+
def writer(csvfile: Any, dialect: Any = ..., **fmtparams: Any) -> _writer: ...
40+
def reader(csvfile: Iterator[str], dialect: Any = ..., **fmtparams: Any) -> _reader: ...
41+
def register_dialect(name: str, dialect: Any = ..., **fmtparams: Any) -> None: ...
42+
def unregister_dialect(name: str) -> None: ...
43+
def get_dialect(name: str) -> Dialect: ...
44+
def list_dialects() -> List[str]: ...
45+
def field_size_limit(new_limit: int = ...) -> int: ...

stdlib/2and3/csv.pyi

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
from collections import OrderedDict
2+
import sys
3+
from typing import Any, Dict, Iterable, Iterator, List, Optional, Sequence, Union
4+
5+
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
6+
7+
_Dialect = Union[str, Dialect]
8+
_DictRow = Dict[str, Any]
9+
10+
class Dialect:
11+
delimiter = ... # type: str
12+
quotechar = ... # type: Optional[str]
13+
escapechar = ... # type: Optional[str]
14+
doublequote = ... # type: bool
15+
skipinitialspace = ... # type: bool
16+
lineterminator = ... # type: str
17+
quoting = ... # type: int
18+
def __init__(self) -> None: ...
19+
20+
class excel(Dialect):
21+
delimiter = ... # type: str
22+
quotechar = ... # type: str
23+
doublequote = ... # type: bool
24+
skipinitialspace = ... # type: bool
25+
lineterminator = ... # type: str
26+
quoting = ... # type: int
27+
28+
class excel_tab(excel):
29+
delimiter = ... # type: str
30+
31+
if sys.version_info >= (3,):
32+
class unix_dialect(Dialect):
33+
delimiter = ... # type: str
34+
quotechar = ... # type: str
35+
doublequote = ... # type: bool
36+
skipinitialspace = ... # type: bool
37+
lineterminator = ... # type: str
38+
quoting = ... # type: int
39+
40+
if sys.version_info >= (3, 6):
41+
class DictReader(Iterator[OrderedDict[str, str]]):
42+
restkey = ... # type: Optional[str]
43+
restval = ... # type: Optional[str]
44+
reader = ... # type: _reader
45+
dialect = ... # type: _Dialect
46+
line_num = ... # type: int
47+
fieldnames = ... # type: Sequence[str]
48+
def __init__(self, f: Iterator[str], fieldnames: Sequence[str] = ..., restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ..., *args: Any, **kwds: Any) -> None: ...
49+
else:
50+
class DictReader(Iterator[Dict[str, str]]):
51+
restkey = ... # type: Optional[str]
52+
restval = ... # type: Optional[str]
53+
reader = ... # type: _reader
54+
dialect = ... # type: _Dialect
55+
line_num = ... # type: int
56+
fieldnames = ... # type: Sequence[str]
57+
def __init__(self, f: Iterator[str], fieldnames: Sequence[str] = ..., restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ..., *args: Any, **kwds: Any) -> None: ...
58+
59+
class DictWriter:
60+
fieldnames = ... # type: Sequence[str]
61+
restval = ... # type: Optional[Any]
62+
extrasaction = ... # type: str
63+
writer = ... # type: _writer
64+
def __init__(self, f: Any, fieldnames: Sequence[str], restval: Optional[Any], extrasaction: str = ..., dialect: _Dialect = ..., *args: Any, **kwds: Any) -> None: ...
65+
def writeheader(self) -> None: ...
66+
def writerow(self, rowdict: _DictRow) -> None: ...
67+
def writerows(self, rowdicts: Iterable[_DictRow]) -> None: ...
68+
69+
class Sniffer:
70+
preferred = ... # type: List[str]
71+
def __init__(self) -> None: ...
72+
def sniff(self, sample: str, delimiters: Optional[str] = ...) -> Dialect: ...
73+
def has_header(self, sample: str) -> bool: ...

stdlib/3/csv.pyi

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)