basedpyright 1.13.1 → 1.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pyright-langserver.js +1 -1
- package/dist/pyright-langserver.js.map +1 -1
- package/dist/pyright.js +1 -1
- package/dist/pyright.js.map +1 -1
- package/dist/typeshed-fallback/commit.txt +1 -1
- package/dist/typeshed-fallback/stdlib/VERSIONS +3 -1
- package/dist/typeshed-fallback/stdlib/_ast.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/_bisect.pyi +221 -221
- package/dist/typeshed-fallback/stdlib/_csv.pyi +213 -213
- package/dist/typeshed-fallback/stdlib/_curses.pyi +1 -2
- package/dist/typeshed-fallback/stdlib/_heapq.pyi +67 -67
- package/dist/typeshed-fallback/stdlib/_interpchannels.pyi +84 -0
- package/dist/typeshed-fallback/stdlib/_json.pyi +92 -92
- package/dist/typeshed-fallback/stdlib/_lsprof.pyi +92 -92
- package/dist/typeshed-fallback/stdlib/_random.pyi +30 -30
- package/dist/typeshed-fallback/stdlib/_tkinter.pyi +7 -0
- package/dist/typeshed-fallback/stdlib/_weakref.pyi +3 -2
- package/dist/typeshed-fallback/stdlib/argparse.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/array.pyi +281 -281
- package/dist/typeshed-fallback/stdlib/asyncio/events.pyi +56 -37
- package/dist/typeshed-fallback/stdlib/asyncio/tasks.pyi +4 -1
- package/dist/typeshed-fallback/stdlib/asyncio/unix_events.pyi +156 -134
- package/dist/typeshed-fallback/stdlib/asyncio/windows_events.pyi +3 -2
- package/dist/typeshed-fallback/stdlib/audioop.pyi +95 -95
- package/dist/typeshed-fallback/stdlib/binascii.pyi +123 -123
- package/dist/typeshed-fallback/stdlib/cmath.pyi +112 -112
- package/dist/typeshed-fallback/stdlib/dataclasses.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/logging/__init__.pyi +2 -5
- package/dist/typeshed-fallback/stdlib/math.pyi +424 -424
- package/dist/typeshed-fallback/stdlib/mmap.pyi +160 -154
- package/dist/typeshed-fallback/stdlib/multiprocessing/context.pyi +10 -6
- package/dist/typeshed-fallback/stdlib/multiprocessing/sharedctypes.pyi +33 -12
- package/dist/typeshed-fallback/stdlib/os/__init__.pyi +10 -10
- package/dist/typeshed-fallback/stdlib/posixpath.pyi +3 -13
- package/dist/typeshed-fallback/stdlib/spwd.pyi +9 -0
- package/dist/typeshed-fallback/stdlib/subprocess.pyi +8 -0
- package/dist/typeshed-fallback/stdlib/tarfile.pyi +23 -1
- package/dist/typeshed-fallback/stdlib/telnetlib.pyi +1 -0
- package/dist/typeshed-fallback/stdlib/typing.pyi +21 -2
- package/dist/typeshed-fallback/stdlib/weakref.pyi +4 -1
- package/dist/typeshed-fallback/stdlib/xml/sax/handler.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/zlib.pyi +157 -157
- package/dist/typeshed-fallback/stubs/Flask-SocketIO/flask_socketio/__init__.pyi +4 -4
- package/dist/typeshed-fallback/stubs/aiofiles/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/base.pyi +6 -20
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/os.pyi +2 -0
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/ospath.pyi +5 -3
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/tempfile/__init__.pyi +143 -79
- package/dist/typeshed-fallback/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +5 -5
- package/dist/typeshed-fallback/stubs/assertpy/assertpy/extracting.pyi +7 -1
- package/dist/typeshed-fallback/stubs/docker/docker/_types.pyi +8 -0
- package/dist/typeshed-fallback/stubs/docker/docker/api/container.pyi +2 -2
- package/dist/typeshed-fallback/stubs/docker/docker/api/image.pyi +3 -2
- package/dist/typeshed-fallback/stubs/docker/docker/api/network.pyi +32 -15
- package/dist/typeshed-fallback/stubs/docker/docker/models/containers.pyi +36 -7
- package/dist/typeshed-fallback/stubs/docker/docker/models/images.pyi +67 -5
- package/dist/typeshed-fallback/stubs/docker/docker/models/networks.pyi +20 -3
- package/dist/typeshed-fallback/stubs/docker/docker/types/containers.pyi +78 -70
- package/dist/typeshed-fallback/stubs/docker/docker/utils/json_stream.pyi +4 -7
- package/dist/typeshed-fallback/stubs/flake8/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/fpdf2/fpdf/fpdf.pyi +16 -5
- package/dist/typeshed-fallback/stubs/fpdf2/fpdf/image_datastructures.pyi +2 -1
- package/dist/typeshed-fallback/stubs/fpdf2/fpdf/table.pyi +4 -2
- package/dist/typeshed-fallback/stubs/fpdf2/fpdf/text_region.pyi +7 -7
- package/dist/typeshed-fallback/stubs/hdbcli/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/hdbcli/hdbcli/dbapi.pyi +1 -0
- package/dist/typeshed-fallback/stubs/hvac/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/hvac/hvac/api/system_backend/raft.pyi +9 -0
- package/dist/typeshed-fallback/stubs/hvac/hvac/api/system_backend/wrapping.pyi +1 -0
- package/dist/typeshed-fallback/stubs/influxdb-client/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/client/_pages.pyi +37 -0
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/client/bucket_api.pyi +5 -1
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/client/tasks_api.pyi +4 -3
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/domain/bucket.pyi +6 -6
- package/dist/typeshed-fallback/stubs/influxdb-client/influxdb_client/domain/task.pyi +6 -6
- package/dist/typeshed-fallback/stubs/networkx/METADATA.toml +3 -1
- package/dist/typeshed-fallback/stubs/olefile/olefile/olefile.pyi +41 -31
- package/dist/typeshed-fallback/stubs/openpyxl/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/cell/rich_text.pyi +3 -0
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/chart/trendline.pyi +1 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/descriptors/base.pyi +1 -1
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/descriptors/container.pyi +18 -0
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/descriptors/sequence.pyi +20 -12
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/packaging/custom.pyi +1 -1
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/packaging/extended.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/packaging/relationship.pyi +6 -11
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/pivot/cache.pyi +66 -135
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/pivot/fields.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/styles/alignment.pyi +0 -1
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/styles/borders.pyi +0 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/styles/fills.pyi +3 -3
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/styles/named_styles.pyi +5 -10
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/utils/cell.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/utils/indexed_list.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/workbook/defined_name.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/_read_only.pyi +11 -3
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi +2 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/dimensions.pyi +6 -3
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/filters.pyi +26 -22
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/hyperlink.pyi +3 -5
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/views.pyi +5 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/worksheet.pyi +4 -2
- package/dist/typeshed-fallback/stubs/peewee/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/peewee/peewee.pyi +6 -1
- package/dist/typeshed-fallback/stubs/protobuf/METADATA.toml +2 -2
- package/dist/typeshed-fallback/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +84 -15
- package/dist/typeshed-fallback/stubs/psutil/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/__init__.pyi +3 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_common.pyi +0 -2
- package/dist/typeshed-fallback/stubs/psutil/psutil/_compat.pyi +0 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_psaix.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_psbsd.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_pslinux.pyi +2 -2
- package/dist/typeshed-fallback/stubs/psutil/psutil/_psosx.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_pssunos.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_psutil_osx.pyi +1 -1
- package/dist/typeshed-fallback/stubs/psutil/psutil/_pswindows.pyi +1 -1
- package/dist/typeshed-fallback/stubs/pyinstaller/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/pyinstaller/PyInstaller/__main__.pyi +1 -0
- package/dist/typeshed-fallback/stubs/pyinstaller/PyInstaller/building/splash.pyi +0 -2
- package/dist/typeshed-fallback/stubs/pyinstaller/PyInstaller/compat.pyi +2 -3
- package/dist/typeshed-fallback/stubs/reportlab/METADATA.toml +3 -2
- package/dist/typeshed-fallback/stubs/requests/requests/models.pyi +2 -2
- package/dist/typeshed-fallback/stubs/seaborn/METADATA.toml +2 -1
- package/dist/typeshed-fallback/stubs/setuptools/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/setuptools/pkg_resources/__init__.pyi +80 -50
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/__init__.pyi +2 -4
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/build_meta.pyi +6 -3
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/bdist_egg.pyi +3 -9
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/bdist_wheel.pyi +61 -0
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/build_ext.pyi +2 -2
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/build_py.pyi +12 -1
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/easy_install.pyi +1 -1
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/egg_info.pyi +4 -4
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/command/install_lib.pyi +3 -4
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/compat/py311.pyi +1 -1
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/config/expand.pyi +0 -1
- package/dist/typeshed-fallback/stubs/shapely/METADATA.toml +2 -1
- package/dist/typeshed-fallback/stubs/shapely/shapely/_geometry.pyi +3 -3
- package/dist/typeshed-fallback/stubs/shapely/shapely/constructive.pyi +6 -6
- package/dist/typeshed-fallback/stubs/shapely/shapely/geometry/base.pyi +3 -3
- package/dist/typeshed-fallback/stubs/shapely/shapely/io.pyi +2 -2
- package/dist/typeshed-fallback/stubs/shapely/shapely/strtree.pyi +9 -9
- package/dist/typeshed-fallback/stubs/tree-sitter-languages/METADATA.toml +1 -1
- package/package.json +1 -1
- package/dist/typeshed-fallback/stubs/tree-sitter/METADATA.toml +0 -7
- package/dist/typeshed-fallback/stubs/tree-sitter/tree_sitter/__init__.pyi +0 -17
- package/dist/typeshed-fallback/stubs/tree-sitter/tree_sitter/binding.pyi +0 -115
|
@@ -1,213 +1,213 @@
|
|
|
1
|
-
r"""
|
|
2
|
-
CSV parsing and writing.
|
|
3
|
-
|
|
4
|
-
This module provides classes that assist in the reading and writing
|
|
5
|
-
of Comma Separated Value (CSV) files, and implements the interface
|
|
6
|
-
described by PEP 305. Although many CSV files are simple to parse,
|
|
7
|
-
the format is not formally defined by a stable specification and
|
|
8
|
-
is subtle enough that parsing lines of a CSV file with something
|
|
9
|
-
like line.split(",") is bound to fail. The module supports three
|
|
10
|
-
basic APIs: reading, writing, and registration of dialects.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
DIALECT REGISTRATION:
|
|
14
|
-
|
|
15
|
-
Readers and writers support a dialect argument, which is a convenient
|
|
16
|
-
handle on a group of settings. When the dialect argument is a string,
|
|
17
|
-
it identifies one of the dialects previously registered with the module.
|
|
18
|
-
If it is a class or instance, the attributes of the argument are used as
|
|
19
|
-
the settings for the reader or writer:
|
|
20
|
-
|
|
21
|
-
class excel:
|
|
22
|
-
delimiter = ','
|
|
23
|
-
quotechar = '"'
|
|
24
|
-
escapechar = None
|
|
25
|
-
doublequote = True
|
|
26
|
-
skipinitialspace = False
|
|
27
|
-
lineterminator = '\r\n'
|
|
28
|
-
quoting = QUOTE_MINIMAL
|
|
29
|
-
|
|
30
|
-
SETTINGS:
|
|
31
|
-
|
|
32
|
-
* quotechar - specifies a one-character string to use as the
|
|
33
|
-
quoting character. It defaults to '"'.
|
|
34
|
-
* delimiter - specifies a one-character string to use as the
|
|
35
|
-
field separator. It defaults to ','.
|
|
36
|
-
* skipinitialspace - specifies how to interpret whitespace which
|
|
37
|
-
immediately follows a delimiter. It defaults to False, which
|
|
38
|
-
means that whitespace immediately following a delimiter is part
|
|
39
|
-
of the following field.
|
|
40
|
-
* lineterminator - specifies the character sequence which should
|
|
41
|
-
terminate rows.
|
|
42
|
-
* quoting - controls when quotes should be generated by the writer.
|
|
43
|
-
It can take on any of the following module constants:
|
|
44
|
-
|
|
45
|
-
csv.QUOTE_MINIMAL means only when required, for example, when a
|
|
46
|
-
field contains either the quotechar or the delimiter
|
|
47
|
-
csv.QUOTE_ALL means that quotes are always placed around fields.
|
|
48
|
-
csv.QUOTE_NONNUMERIC means that quotes are always placed around
|
|
49
|
-
fields which do not parse as integers or floating point
|
|
50
|
-
numbers.
|
|
51
|
-
csv.QUOTE_NONE means that quotes are never placed around fields.
|
|
52
|
-
* escapechar - specifies a one-character string used to escape
|
|
53
|
-
the delimiter when quoting is set to QUOTE_NONE.
|
|
54
|
-
* doublequote - controls the handling of quotes inside fields. When
|
|
55
|
-
True, two consecutive quotes are interpreted as one during read,
|
|
56
|
-
and when writing, each quote character embedded in the data is
|
|
57
|
-
written as two quotes
|
|
58
|
-
"""
|
|
59
|
-
|
|
60
|
-
import sys
|
|
61
|
-
from _typeshed import SupportsWrite
|
|
62
|
-
from collections.abc import Iterable, Iterator
|
|
63
|
-
from typing import Any, Final, Literal
|
|
64
|
-
from typing_extensions import TypeAlias
|
|
65
|
-
|
|
66
|
-
__version__: Final[str]
|
|
67
|
-
|
|
68
|
-
QUOTE_ALL: Literal[1]
|
|
69
|
-
QUOTE_MINIMAL: Literal[0]
|
|
70
|
-
QUOTE_NONE: Literal[3]
|
|
71
|
-
QUOTE_NONNUMERIC: Literal[2]
|
|
72
|
-
if sys.version_info >= (3, 12):
|
|
73
|
-
QUOTE_STRINGS: Literal[4]
|
|
74
|
-
QUOTE_NOTNULL: Literal[5]
|
|
75
|
-
|
|
76
|
-
# Ideally this would be `QUOTE_ALL | QUOTE_MINIMAL | QUOTE_NONE | QUOTE_NONNUMERIC`
|
|
77
|
-
# However, using literals in situations like these can cause false-positives (see #7258)
|
|
78
|
-
_QuotingType: TypeAlias = int
|
|
79
|
-
|
|
80
|
-
class Error(Exception): ...
|
|
81
|
-
|
|
82
|
-
class Dialect:
|
|
83
|
-
"""
|
|
84
|
-
CSV dialect
|
|
85
|
-
|
|
86
|
-
The Dialect type records CSV parsing and generation options.
|
|
87
|
-
"""
|
|
88
|
-
delimiter: str
|
|
89
|
-
quotechar: str | None
|
|
90
|
-
escapechar: str | None
|
|
91
|
-
doublequote: bool
|
|
92
|
-
skipinitialspace: bool
|
|
93
|
-
lineterminator: str
|
|
94
|
-
quoting: _QuotingType
|
|
95
|
-
strict: bool
|
|
96
|
-
def __init__(self) -> None: ...
|
|
97
|
-
|
|
98
|
-
_DialectLike: TypeAlias = str | Dialect | type[Dialect]
|
|
99
|
-
|
|
100
|
-
class _reader(Iterator[list[str]]):
|
|
101
|
-
@property
|
|
102
|
-
def dialect(self) -> Dialect: ...
|
|
103
|
-
line_num: int
|
|
104
|
-
def __next__(self) -> list[str]: ...
|
|
105
|
-
|
|
106
|
-
class _writer:
|
|
107
|
-
@property
|
|
108
|
-
def dialect(self) -> Dialect: ...
|
|
109
|
-
def writerow(self, row: Iterable[Any]) -> Any: ...
|
|
110
|
-
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
|
|
111
|
-
|
|
112
|
-
def writer(
|
|
113
|
-
csvfile: SupportsWrite[str],
|
|
114
|
-
dialect: _DialectLike = "excel",
|
|
115
|
-
*,
|
|
116
|
-
delimiter: str = ",",
|
|
117
|
-
quotechar: str | None = '"',
|
|
118
|
-
escapechar: str | None = None,
|
|
119
|
-
doublequote: bool = True,
|
|
120
|
-
skipinitialspace: bool = False,
|
|
121
|
-
lineterminator: str = "\r\n",
|
|
122
|
-
quoting: _QuotingType = 0,
|
|
123
|
-
strict: bool = False,
|
|
124
|
-
) -> _writer:
|
|
125
|
-
"""
|
|
126
|
-
csv_writer = csv.writer(fileobj [, dialect='excel']
|
|
127
|
-
[optional keyword args])
|
|
128
|
-
for row in sequence:
|
|
129
|
-
csv_writer.writerow(row)
|
|
130
|
-
|
|
131
|
-
[or]
|
|
132
|
-
|
|
133
|
-
csv_writer = csv.writer(fileobj [, dialect='excel']
|
|
134
|
-
[optional keyword args])
|
|
135
|
-
csv_writer.writerows(rows)
|
|
136
|
-
|
|
137
|
-
The "fileobj" argument can be any object that supports the file API.
|
|
138
|
-
"""
|
|
139
|
-
...
|
|
140
|
-
def reader(
|
|
141
|
-
csvfile: Iterable[str],
|
|
142
|
-
dialect: _DialectLike = "excel",
|
|
143
|
-
*,
|
|
144
|
-
delimiter: str = ",",
|
|
145
|
-
quotechar: str | None = '"',
|
|
146
|
-
escapechar: str | None = None,
|
|
147
|
-
doublequote: bool = True,
|
|
148
|
-
skipinitialspace: bool = False,
|
|
149
|
-
lineterminator: str = "\r\n",
|
|
150
|
-
quoting: _QuotingType = 0,
|
|
151
|
-
strict: bool = False,
|
|
152
|
-
) -> _reader:
|
|
153
|
-
"""
|
|
154
|
-
csv_reader = reader(iterable [, dialect='excel']
|
|
155
|
-
[optional keyword args])
|
|
156
|
-
for row in csv_reader:
|
|
157
|
-
process(row)
|
|
158
|
-
|
|
159
|
-
The "iterable" argument can be any object that returns a line
|
|
160
|
-
of input for each iteration, such as a file object or a list. The
|
|
161
|
-
optional "dialect" parameter is discussed below. The function
|
|
162
|
-
also accepts optional keyword arguments which override settings
|
|
163
|
-
provided by the dialect.
|
|
164
|
-
|
|
165
|
-
The returned object is an iterator. Each iteration returns a row
|
|
166
|
-
of the CSV file (which can span multiple input lines).
|
|
167
|
-
"""
|
|
168
|
-
...
|
|
169
|
-
def register_dialect(
|
|
170
|
-
name: str,
|
|
171
|
-
dialect: type[Dialect] = ...,
|
|
172
|
-
*,
|
|
173
|
-
delimiter: str = ",",
|
|
174
|
-
quotechar: str | None = '"',
|
|
175
|
-
escapechar: str | None = None,
|
|
176
|
-
doublequote: bool = True,
|
|
177
|
-
skipinitialspace: bool = False,
|
|
178
|
-
lineterminator: str = "\r\n",
|
|
179
|
-
quoting: _QuotingType = 0,
|
|
180
|
-
strict: bool = False,
|
|
181
|
-
) -> None:
|
|
182
|
-
"""
|
|
183
|
-
Create a mapping from a string name to a dialect class.
|
|
184
|
-
dialect = csv.register_dialect(name[, dialect[, **fmtparams]])
|
|
185
|
-
"""
|
|
186
|
-
...
|
|
187
|
-
def unregister_dialect(name: str) -> None:
|
|
188
|
-
"""
|
|
189
|
-
Delete the name/dialect mapping associated with a string name.
|
|
190
|
-
csv.unregister_dialect(name)
|
|
191
|
-
"""
|
|
192
|
-
...
|
|
193
|
-
def get_dialect(name: str) -> Dialect:
|
|
194
|
-
"""
|
|
195
|
-
Return the dialect instance associated with name.
|
|
196
|
-
dialect = csv.get_dialect(name)
|
|
197
|
-
"""
|
|
198
|
-
...
|
|
199
|
-
def list_dialects() -> list[str]:
|
|
200
|
-
"""
|
|
201
|
-
Return a list of all know dialect names.
|
|
202
|
-
names = csv.list_dialects()
|
|
203
|
-
"""
|
|
204
|
-
...
|
|
205
|
-
def field_size_limit(new_limit: int = ...) -> int:
|
|
206
|
-
"""
|
|
207
|
-
Sets an upper limit on parsed fields.
|
|
208
|
-
csv.field_size_limit([limit])
|
|
209
|
-
|
|
210
|
-
Returns old limit. If limit is not given, no new limit is set and
|
|
211
|
-
the old limit is returned
|
|
212
|
-
"""
|
|
213
|
-
...
|
|
1
|
+
r"""
|
|
2
|
+
CSV parsing and writing.
|
|
3
|
+
|
|
4
|
+
This module provides classes that assist in the reading and writing
|
|
5
|
+
of Comma Separated Value (CSV) files, and implements the interface
|
|
6
|
+
described by PEP 305. Although many CSV files are simple to parse,
|
|
7
|
+
the format is not formally defined by a stable specification and
|
|
8
|
+
is subtle enough that parsing lines of a CSV file with something
|
|
9
|
+
like line.split(",") is bound to fail. The module supports three
|
|
10
|
+
basic APIs: reading, writing, and registration of dialects.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
DIALECT REGISTRATION:
|
|
14
|
+
|
|
15
|
+
Readers and writers support a dialect argument, which is a convenient
|
|
16
|
+
handle on a group of settings. When the dialect argument is a string,
|
|
17
|
+
it identifies one of the dialects previously registered with the module.
|
|
18
|
+
If it is a class or instance, the attributes of the argument are used as
|
|
19
|
+
the settings for the reader or writer:
|
|
20
|
+
|
|
21
|
+
class excel:
|
|
22
|
+
delimiter = ','
|
|
23
|
+
quotechar = '"'
|
|
24
|
+
escapechar = None
|
|
25
|
+
doublequote = True
|
|
26
|
+
skipinitialspace = False
|
|
27
|
+
lineterminator = '\r\n'
|
|
28
|
+
quoting = QUOTE_MINIMAL
|
|
29
|
+
|
|
30
|
+
SETTINGS:
|
|
31
|
+
|
|
32
|
+
* quotechar - specifies a one-character string to use as the
|
|
33
|
+
quoting character. It defaults to '"'.
|
|
34
|
+
* delimiter - specifies a one-character string to use as the
|
|
35
|
+
field separator. It defaults to ','.
|
|
36
|
+
* skipinitialspace - specifies how to interpret whitespace which
|
|
37
|
+
immediately follows a delimiter. It defaults to False, which
|
|
38
|
+
means that whitespace immediately following a delimiter is part
|
|
39
|
+
of the following field.
|
|
40
|
+
* lineterminator - specifies the character sequence which should
|
|
41
|
+
terminate rows.
|
|
42
|
+
* quoting - controls when quotes should be generated by the writer.
|
|
43
|
+
It can take on any of the following module constants:
|
|
44
|
+
|
|
45
|
+
csv.QUOTE_MINIMAL means only when required, for example, when a
|
|
46
|
+
field contains either the quotechar or the delimiter
|
|
47
|
+
csv.QUOTE_ALL means that quotes are always placed around fields.
|
|
48
|
+
csv.QUOTE_NONNUMERIC means that quotes are always placed around
|
|
49
|
+
fields which do not parse as integers or floating point
|
|
50
|
+
numbers.
|
|
51
|
+
csv.QUOTE_NONE means that quotes are never placed around fields.
|
|
52
|
+
* escapechar - specifies a one-character string used to escape
|
|
53
|
+
the delimiter when quoting is set to QUOTE_NONE.
|
|
54
|
+
* doublequote - controls the handling of quotes inside fields. When
|
|
55
|
+
True, two consecutive quotes are interpreted as one during read,
|
|
56
|
+
and when writing, each quote character embedded in the data is
|
|
57
|
+
written as two quotes
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
import sys
|
|
61
|
+
from _typeshed import SupportsWrite
|
|
62
|
+
from collections.abc import Iterable, Iterator
|
|
63
|
+
from typing import Any, Final, Literal
|
|
64
|
+
from typing_extensions import TypeAlias
|
|
65
|
+
|
|
66
|
+
__version__: Final[str]
|
|
67
|
+
|
|
68
|
+
QUOTE_ALL: Literal[1]
|
|
69
|
+
QUOTE_MINIMAL: Literal[0]
|
|
70
|
+
QUOTE_NONE: Literal[3]
|
|
71
|
+
QUOTE_NONNUMERIC: Literal[2]
|
|
72
|
+
if sys.version_info >= (3, 12):
|
|
73
|
+
QUOTE_STRINGS: Literal[4]
|
|
74
|
+
QUOTE_NOTNULL: Literal[5]
|
|
75
|
+
|
|
76
|
+
# Ideally this would be `QUOTE_ALL | QUOTE_MINIMAL | QUOTE_NONE | QUOTE_NONNUMERIC`
|
|
77
|
+
# However, using literals in situations like these can cause false-positives (see #7258)
|
|
78
|
+
_QuotingType: TypeAlias = int
|
|
79
|
+
|
|
80
|
+
class Error(Exception): ...
|
|
81
|
+
|
|
82
|
+
class Dialect:
|
|
83
|
+
"""
|
|
84
|
+
CSV dialect
|
|
85
|
+
|
|
86
|
+
The Dialect type records CSV parsing and generation options.
|
|
87
|
+
"""
|
|
88
|
+
delimiter: str
|
|
89
|
+
quotechar: str | None
|
|
90
|
+
escapechar: str | None
|
|
91
|
+
doublequote: bool
|
|
92
|
+
skipinitialspace: bool
|
|
93
|
+
lineterminator: str
|
|
94
|
+
quoting: _QuotingType
|
|
95
|
+
strict: bool
|
|
96
|
+
def __init__(self) -> None: ...
|
|
97
|
+
|
|
98
|
+
_DialectLike: TypeAlias = str | Dialect | type[Dialect]
|
|
99
|
+
|
|
100
|
+
class _reader(Iterator[list[str]]):
|
|
101
|
+
@property
|
|
102
|
+
def dialect(self) -> Dialect: ...
|
|
103
|
+
line_num: int
|
|
104
|
+
def __next__(self) -> list[str]: ...
|
|
105
|
+
|
|
106
|
+
class _writer:
|
|
107
|
+
@property
|
|
108
|
+
def dialect(self) -> Dialect: ...
|
|
109
|
+
def writerow(self, row: Iterable[Any]) -> Any: ...
|
|
110
|
+
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
|
|
111
|
+
|
|
112
|
+
def writer(
|
|
113
|
+
csvfile: SupportsWrite[str],
|
|
114
|
+
dialect: _DialectLike = "excel",
|
|
115
|
+
*,
|
|
116
|
+
delimiter: str = ",",
|
|
117
|
+
quotechar: str | None = '"',
|
|
118
|
+
escapechar: str | None = None,
|
|
119
|
+
doublequote: bool = True,
|
|
120
|
+
skipinitialspace: bool = False,
|
|
121
|
+
lineterminator: str = "\r\n",
|
|
122
|
+
quoting: _QuotingType = 0,
|
|
123
|
+
strict: bool = False,
|
|
124
|
+
) -> _writer:
|
|
125
|
+
"""
|
|
126
|
+
csv_writer = csv.writer(fileobj [, dialect='excel']
|
|
127
|
+
[optional keyword args])
|
|
128
|
+
for row in sequence:
|
|
129
|
+
csv_writer.writerow(row)
|
|
130
|
+
|
|
131
|
+
[or]
|
|
132
|
+
|
|
133
|
+
csv_writer = csv.writer(fileobj [, dialect='excel']
|
|
134
|
+
[optional keyword args])
|
|
135
|
+
csv_writer.writerows(rows)
|
|
136
|
+
|
|
137
|
+
The "fileobj" argument can be any object that supports the file API.
|
|
138
|
+
"""
|
|
139
|
+
...
|
|
140
|
+
def reader(
|
|
141
|
+
csvfile: Iterable[str],
|
|
142
|
+
dialect: _DialectLike = "excel",
|
|
143
|
+
*,
|
|
144
|
+
delimiter: str = ",",
|
|
145
|
+
quotechar: str | None = '"',
|
|
146
|
+
escapechar: str | None = None,
|
|
147
|
+
doublequote: bool = True,
|
|
148
|
+
skipinitialspace: bool = False,
|
|
149
|
+
lineterminator: str = "\r\n",
|
|
150
|
+
quoting: _QuotingType = 0,
|
|
151
|
+
strict: bool = False,
|
|
152
|
+
) -> _reader:
|
|
153
|
+
"""
|
|
154
|
+
csv_reader = reader(iterable [, dialect='excel']
|
|
155
|
+
[optional keyword args])
|
|
156
|
+
for row in csv_reader:
|
|
157
|
+
process(row)
|
|
158
|
+
|
|
159
|
+
The "iterable" argument can be any object that returns a line
|
|
160
|
+
of input for each iteration, such as a file object or a list. The
|
|
161
|
+
optional "dialect" parameter is discussed below. The function
|
|
162
|
+
also accepts optional keyword arguments which override settings
|
|
163
|
+
provided by the dialect.
|
|
164
|
+
|
|
165
|
+
The returned object is an iterator. Each iteration returns a row
|
|
166
|
+
of the CSV file (which can span multiple input lines).
|
|
167
|
+
"""
|
|
168
|
+
...
|
|
169
|
+
def register_dialect(
|
|
170
|
+
name: str,
|
|
171
|
+
dialect: type[Dialect] = ...,
|
|
172
|
+
*,
|
|
173
|
+
delimiter: str = ",",
|
|
174
|
+
quotechar: str | None = '"',
|
|
175
|
+
escapechar: str | None = None,
|
|
176
|
+
doublequote: bool = True,
|
|
177
|
+
skipinitialspace: bool = False,
|
|
178
|
+
lineterminator: str = "\r\n",
|
|
179
|
+
quoting: _QuotingType = 0,
|
|
180
|
+
strict: bool = False,
|
|
181
|
+
) -> None:
|
|
182
|
+
"""
|
|
183
|
+
Create a mapping from a string name to a dialect class.
|
|
184
|
+
dialect = csv.register_dialect(name[, dialect[, **fmtparams]])
|
|
185
|
+
"""
|
|
186
|
+
...
|
|
187
|
+
def unregister_dialect(name: str) -> None:
|
|
188
|
+
"""
|
|
189
|
+
Delete the name/dialect mapping associated with a string name.
|
|
190
|
+
csv.unregister_dialect(name)
|
|
191
|
+
"""
|
|
192
|
+
...
|
|
193
|
+
def get_dialect(name: str) -> Dialect:
|
|
194
|
+
"""
|
|
195
|
+
Return the dialect instance associated with name.
|
|
196
|
+
dialect = csv.get_dialect(name)
|
|
197
|
+
"""
|
|
198
|
+
...
|
|
199
|
+
def list_dialects() -> list[str]:
|
|
200
|
+
"""
|
|
201
|
+
Return a list of all know dialect names.
|
|
202
|
+
names = csv.list_dialects()
|
|
203
|
+
"""
|
|
204
|
+
...
|
|
205
|
+
def field_size_limit(new_limit: int = ...) -> int:
|
|
206
|
+
"""
|
|
207
|
+
Sets an upper limit on parsed fields.
|
|
208
|
+
csv.field_size_limit([limit])
|
|
209
|
+
|
|
210
|
+
Returns old limit. If limit is not given, no new limit is set and
|
|
211
|
+
the old limit is returned
|
|
212
|
+
"""
|
|
213
|
+
...
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Heap queue algorithm (a.k.a. priority queue).
|
|
3
|
-
|
|
4
|
-
Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for
|
|
5
|
-
all k, counting elements from 0. For the sake of comparison,
|
|
6
|
-
non-existing elements are considered to be infinite. The interesting
|
|
7
|
-
property of a heap is that a[0] is always its smallest element.
|
|
8
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
|
|
11
|
-
heap = [] # creates an empty heap
|
|
12
|
-
heappush(heap, item) # pushes a new item on the heap
|
|
13
|
-
item = heappop(heap) # pops the smallest item from the heap
|
|
14
|
-
item = heap[0] # smallest item on the heap without popping it
|
|
15
|
-
heapify(x) # transforms list into a heap, in-place, in linear time
|
|
16
|
-
item = heapreplace(heap, item) # pops and returns smallest item, and adds
|
|
17
|
-
# new item; the heap size is unchanged
|
|
18
|
-
|
|
19
|
-
Our API differs from textbook heap algorithms as follows:
|
|
20
|
-
|
|
21
|
-
- We use 0-based indexing. This makes the relationship between the
|
|
22
|
-
index for a node and the indexes for its children slightly less
|
|
23
|
-
obvious, but is more suitable since Python uses 0-based indexing.
|
|
24
|
-
|
|
25
|
-
- Our heappop() method returns the smallest item, not the largest.
|
|
26
|
-
|
|
27
|
-
These two make it possible to view the heap as a regular Python list
|
|
28
|
-
without surprises: heap[0] is the smallest item, and heap.sort()
|
|
29
|
-
maintains the heap invariant!
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
from typing import Any, Final, TypeVar
|
|
33
|
-
|
|
34
|
-
_T = TypeVar("_T")
|
|
35
|
-
|
|
36
|
-
__about__: Final[str]
|
|
37
|
-
|
|
38
|
-
def heapify(heap: list[Any], /) -> None:
|
|
39
|
-
"""Transform list into a heap, in-place, in O(len(heap)) time."""
|
|
40
|
-
...
|
|
41
|
-
def heappop(heap: list[_T], /) -> _T:
|
|
42
|
-
"""Pop the smallest item off the heap, maintaining the heap invariant."""
|
|
43
|
-
...
|
|
44
|
-
def heappush(heap: list[_T], item: _T, /) -> None:
|
|
45
|
-
"""Push item onto heap, maintaining the heap invariant."""
|
|
46
|
-
...
|
|
47
|
-
def heappushpop(heap: list[_T], item: _T, /) -> _T:
|
|
48
|
-
"""
|
|
49
|
-
Push item on the heap, then pop and return the smallest item from the heap.
|
|
50
|
-
|
|
51
|
-
The combined action runs more efficiently than heappush() followed by
|
|
52
|
-
a separate call to heappop().
|
|
53
|
-
"""
|
|
54
|
-
...
|
|
55
|
-
def heapreplace(heap: list[_T], item: _T, /) -> _T:
|
|
56
|
-
"""
|
|
57
|
-
Pop and return the current smallest value, and add the new item.
|
|
58
|
-
|
|
59
|
-
This is more efficient than heappop() followed by heappush(), and can be
|
|
60
|
-
more appropriate when using a fixed-size heap. Note that the value
|
|
61
|
-
returned may be larger than item! That constrains reasonable uses of
|
|
62
|
-
this routine unless written as part of a conditional replacement:
|
|
63
|
-
|
|
64
|
-
if item > heap[0]:
|
|
65
|
-
item = heapreplace(heap, item)
|
|
66
|
-
"""
|
|
67
|
-
...
|
|
1
|
+
"""
|
|
2
|
+
Heap queue algorithm (a.k.a. priority queue).
|
|
3
|
+
|
|
4
|
+
Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for
|
|
5
|
+
all k, counting elements from 0. For the sake of comparison,
|
|
6
|
+
non-existing elements are considered to be infinite. The interesting
|
|
7
|
+
property of a heap is that a[0] is always its smallest element.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
|
|
11
|
+
heap = [] # creates an empty heap
|
|
12
|
+
heappush(heap, item) # pushes a new item on the heap
|
|
13
|
+
item = heappop(heap) # pops the smallest item from the heap
|
|
14
|
+
item = heap[0] # smallest item on the heap without popping it
|
|
15
|
+
heapify(x) # transforms list into a heap, in-place, in linear time
|
|
16
|
+
item = heapreplace(heap, item) # pops and returns smallest item, and adds
|
|
17
|
+
# new item; the heap size is unchanged
|
|
18
|
+
|
|
19
|
+
Our API differs from textbook heap algorithms as follows:
|
|
20
|
+
|
|
21
|
+
- We use 0-based indexing. This makes the relationship between the
|
|
22
|
+
index for a node and the indexes for its children slightly less
|
|
23
|
+
obvious, but is more suitable since Python uses 0-based indexing.
|
|
24
|
+
|
|
25
|
+
- Our heappop() method returns the smallest item, not the largest.
|
|
26
|
+
|
|
27
|
+
These two make it possible to view the heap as a regular Python list
|
|
28
|
+
without surprises: heap[0] is the smallest item, and heap.sort()
|
|
29
|
+
maintains the heap invariant!
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
from typing import Any, Final, TypeVar
|
|
33
|
+
|
|
34
|
+
_T = TypeVar("_T")
|
|
35
|
+
|
|
36
|
+
__about__: Final[str]
|
|
37
|
+
|
|
38
|
+
def heapify(heap: list[Any], /) -> None:
|
|
39
|
+
"""Transform list into a heap, in-place, in O(len(heap)) time."""
|
|
40
|
+
...
|
|
41
|
+
def heappop(heap: list[_T], /) -> _T:
|
|
42
|
+
"""Pop the smallest item off the heap, maintaining the heap invariant."""
|
|
43
|
+
...
|
|
44
|
+
def heappush(heap: list[_T], item: _T, /) -> None:
|
|
45
|
+
"""Push item onto heap, maintaining the heap invariant."""
|
|
46
|
+
...
|
|
47
|
+
def heappushpop(heap: list[_T], item: _T, /) -> _T:
|
|
48
|
+
"""
|
|
49
|
+
Push item on the heap, then pop and return the smallest item from the heap.
|
|
50
|
+
|
|
51
|
+
The combined action runs more efficiently than heappush() followed by
|
|
52
|
+
a separate call to heappop().
|
|
53
|
+
"""
|
|
54
|
+
...
|
|
55
|
+
def heapreplace(heap: list[_T], item: _T, /) -> _T:
|
|
56
|
+
"""
|
|
57
|
+
Pop and return the current smallest value, and add the new item.
|
|
58
|
+
|
|
59
|
+
This is more efficient than heappop() followed by heappush(), and can be
|
|
60
|
+
more appropriate when using a fixed-size heap. Note that the value
|
|
61
|
+
returned may be larger than item! That constrains reasonable uses of
|
|
62
|
+
this routine unless written as part of a conditional replacement:
|
|
63
|
+
|
|
64
|
+
if item > heap[0]:
|
|
65
|
+
item = heapreplace(heap, item)
|
|
66
|
+
"""
|
|
67
|
+
...
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from _typeshed import structseq
|
|
2
|
+
from typing import Final, Literal, SupportsIndex, final
|
|
3
|
+
from typing_extensions import Buffer, Self
|
|
4
|
+
|
|
5
|
+
class ChannelError(RuntimeError): ...
|
|
6
|
+
class ChannelClosedError(ChannelError): ...
|
|
7
|
+
class ChannelEmptyError(ChannelError): ...
|
|
8
|
+
class ChannelNotEmptyError(ChannelError): ...
|
|
9
|
+
class ChannelNotFoundError(ChannelError): ...
|
|
10
|
+
|
|
11
|
+
# Mark as final, since instantiating ChannelID is not supported.
|
|
12
|
+
@final
|
|
13
|
+
class ChannelID:
|
|
14
|
+
@property
|
|
15
|
+
def end(self) -> Literal["send", "recv", "both"]: ...
|
|
16
|
+
@property
|
|
17
|
+
def send(self) -> Self: ...
|
|
18
|
+
@property
|
|
19
|
+
def recv(self) -> Self: ...
|
|
20
|
+
def __eq__(self, other: object) -> bool: ...
|
|
21
|
+
def __ge__(self, other: ChannelID) -> bool: ...
|
|
22
|
+
def __gt__(self, other: ChannelID) -> bool: ...
|
|
23
|
+
def __hash__(self) -> int: ...
|
|
24
|
+
def __index__(self) -> int: ...
|
|
25
|
+
def __int__(self) -> int: ...
|
|
26
|
+
def __le__(self, other: ChannelID) -> bool: ...
|
|
27
|
+
def __lt__(self, other: ChannelID) -> bool: ...
|
|
28
|
+
def __ne__(self, other: object) -> bool: ...
|
|
29
|
+
|
|
30
|
+
@final
|
|
31
|
+
class ChannelInfo(structseq[int], tuple[bool, bool, bool, int, int, int, int, int]):
|
|
32
|
+
__match_args__: Final = (
|
|
33
|
+
"open",
|
|
34
|
+
"closing",
|
|
35
|
+
"closed",
|
|
36
|
+
"count",
|
|
37
|
+
"num_interp_send",
|
|
38
|
+
"num_interp_send_released",
|
|
39
|
+
"num_interp_recv",
|
|
40
|
+
"num_interp_recv_released",
|
|
41
|
+
)
|
|
42
|
+
@property
|
|
43
|
+
def open(self) -> bool: ...
|
|
44
|
+
@property
|
|
45
|
+
def closing(self) -> bool: ...
|
|
46
|
+
@property
|
|
47
|
+
def closed(self) -> bool: ...
|
|
48
|
+
@property
|
|
49
|
+
def count(self) -> int: ... # type: ignore[override]
|
|
50
|
+
@property
|
|
51
|
+
def num_interp_send(self) -> int: ...
|
|
52
|
+
@property
|
|
53
|
+
def num_interp_send_released(self) -> int: ...
|
|
54
|
+
@property
|
|
55
|
+
def num_interp_recv(self) -> int: ...
|
|
56
|
+
@property
|
|
57
|
+
def num_interp_recv_released(self) -> int: ...
|
|
58
|
+
@property
|
|
59
|
+
def num_interp_both(self) -> int: ...
|
|
60
|
+
@property
|
|
61
|
+
def num_interp_both_recv_released(self) -> int: ...
|
|
62
|
+
@property
|
|
63
|
+
def num_interp_both_send_released(self) -> int: ...
|
|
64
|
+
@property
|
|
65
|
+
def num_interp_both_released(self) -> int: ...
|
|
66
|
+
@property
|
|
67
|
+
def recv_associated(self) -> bool: ...
|
|
68
|
+
@property
|
|
69
|
+
def recv_released(self) -> bool: ...
|
|
70
|
+
@property
|
|
71
|
+
def send_associated(self) -> bool: ...
|
|
72
|
+
@property
|
|
73
|
+
def send_released(self) -> bool: ...
|
|
74
|
+
|
|
75
|
+
def create() -> ChannelID: ...
|
|
76
|
+
def destroy(cid: SupportsIndex) -> None: ...
|
|
77
|
+
def list_all() -> list[ChannelID]: ...
|
|
78
|
+
def list_interpreters(cid: SupportsIndex, *, send: bool) -> list[int]: ...
|
|
79
|
+
def send(cid: SupportsIndex, obj: object, *, blocking: bool = True, timeout: float | None = None) -> None: ...
|
|
80
|
+
def send_buffer(cid: SupportsIndex, obj: Buffer, *, blocking: bool = True, timeout: float | None = None) -> None: ...
|
|
81
|
+
def recv(cid: SupportsIndex, default: object = ...) -> object: ...
|
|
82
|
+
def close(cid: SupportsIndex, *, send: bool = False, recv: bool = False) -> None: ...
|
|
83
|
+
def get_info(cid: SupportsIndex) -> ChannelInfo: ...
|
|
84
|
+
def release(cid: SupportsIndex, *, send: bool = False, recv: bool = False, force: bool = False) -> None: ...
|