-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
csv.pyi
157 lines (147 loc) · 4.42 KB
/
csv.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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,
__version__ as __version__,
_DialectLike,
_QuotingType,
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,
)
if sys.version_info >= (3, 12):
from _csv import QUOTE_NOTNULL as QUOTE_NOTNULL, QUOTE_STRINGS as QUOTE_STRINGS
if sys.version_info >= (3, 10):
from _csv import Reader, Writer
else:
from _csv import _reader as Reader, _writer as Writer
from _typeshed import SupportsWrite
from collections.abc import Collection, Iterable, Mapping, Sequence
from typing import Any, Generic, Literal, TypeVar, overload
from typing_extensions import Self
if sys.version_info >= (3, 12):
from types import GenericAlias
__all__ = [
"QUOTE_MINIMAL",
"QUOTE_ALL",
"QUOTE_NONNUMERIC",
"QUOTE_NONE",
"Error",
"Dialect",
"excel",
"excel_tab",
"field_size_limit",
"reader",
"writer",
"register_dialect",
"get_dialect",
"list_dialects",
"Sniffer",
"unregister_dialect",
"DictReader",
"DictWriter",
"unix_dialect",
]
if sys.version_info >= (3, 12):
__all__ += ["QUOTE_STRINGS", "QUOTE_NOTNULL"]
if sys.version_info < (3, 13):
__all__ += ["__doc__", "__version__"]
_T = TypeVar("_T")
class Dialect:
delimiter: str
quotechar: str | None
escapechar: str | None
doublequote: bool
skipinitialspace: bool
lineterminator: str
quoting: _QuotingType
strict: bool
def __init__(self) -> None: ...
class excel(Dialect): ...
class excel_tab(excel): ...
class unix_dialect(Dialect): ...
class DictReader(Generic[_T]):
fieldnames: Sequence[_T] | None
restkey: _T | None
restval: str | Any | None
reader: Reader
dialect: _DialectLike
line_num: int
@overload
def __init__(
self,
f: Iterable[str],
fieldnames: Sequence[_T],
restkey: _T | None = None,
restval: str | Any | None = None,
dialect: _DialectLike = "excel",
*,
delimiter: str = ",",
quotechar: str | None = '"',
escapechar: str | None = None,
doublequote: bool = True,
skipinitialspace: bool = False,
lineterminator: str = "\r\n",
quoting: _QuotingType = 0,
strict: bool = False,
) -> None: ...
@overload
def __init__(
self: DictReader[str],
f: Iterable[str],
fieldnames: Sequence[str] | None = None,
restkey: str | None = None,
restval: str | None = None,
dialect: _DialectLike = "excel",
*,
delimiter: str = ",",
quotechar: str | None = '"',
escapechar: str | None = None,
doublequote: bool = True,
skipinitialspace: bool = False,
lineterminator: str = "\r\n",
quoting: _QuotingType = 0,
strict: bool = False,
) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> dict[_T | Any, str | Any]: ...
if sys.version_info >= (3, 12):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class DictWriter(Generic[_T]):
fieldnames: Collection[_T]
restval: Any | None
extrasaction: Literal["raise", "ignore"]
writer: Writer
def __init__(
self,
f: SupportsWrite[str],
fieldnames: Collection[_T],
restval: Any | None = "",
extrasaction: Literal["raise", "ignore"] = "raise",
dialect: _DialectLike = "excel",
*,
delimiter: str = ",",
quotechar: str | None = '"',
escapechar: str | None = None,
doublequote: bool = True,
skipinitialspace: bool = False,
lineterminator: str = "\r\n",
quoting: _QuotingType = 0,
strict: bool = False,
) -> None: ...
def writeheader(self) -> Any: ...
def writerow(self, rowdict: Mapping[_T, Any]) -> Any: ...
def writerows(self, rowdicts: Iterable[Mapping[_T, Any]]) -> None: ...
if sys.version_info >= (3, 12):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class Sniffer:
preferred: list[str]
def sniff(self, sample: str, delimiters: str | None = None) -> type[Dialect]: ...
def has_header(self, sample: str) -> bool: ...