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,281 +1,281 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module defines an object type which can efficiently represent
|
|
3
|
-
an array of basic values: characters, integers, floating point
|
|
4
|
-
numbers. Arrays are sequence types and behave very much like lists,
|
|
5
|
-
except that the type of objects stored in them is constrained.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import sys
|
|
9
|
-
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
|
|
10
|
-
from collections.abc import Iterable
|
|
11
|
-
|
|
12
|
-
# pytype crashes if array inherits from collections.abc.MutableSequence instead of typing.MutableSequence
|
|
13
|
-
from typing import Any, Literal, MutableSequence, SupportsIndex, TypeVar, overload # noqa: Y022
|
|
14
|
-
from typing_extensions import Self, TypeAlias
|
|
15
|
-
|
|
16
|
-
if sys.version_info >= (3, 12):
|
|
17
|
-
from types import GenericAlias
|
|
18
|
-
|
|
19
|
-
_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
|
|
20
|
-
_FloatTypeCode: TypeAlias = Literal["f", "d"]
|
|
21
|
-
_UnicodeTypeCode: TypeAlias = Literal["u"]
|
|
22
|
-
_TypeCode: TypeAlias = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode
|
|
23
|
-
|
|
24
|
-
_T = TypeVar("_T", int, float, str)
|
|
25
|
-
|
|
26
|
-
typecodes: str
|
|
27
|
-
|
|
28
|
-
class array(MutableSequence[_T]):
|
|
29
|
-
"""
|
|
30
|
-
array(typecode [, initializer]) -> array
|
|
31
|
-
|
|
32
|
-
Return a new array whose items are restricted by typecode, and
|
|
33
|
-
initialized from the optional initializer value, which must be a list,
|
|
34
|
-
string or iterable over elements of the appropriate type.
|
|
35
|
-
|
|
36
|
-
Arrays represent basic values and behave very much like lists, except
|
|
37
|
-
the type of objects stored in them is constrained. The type is specified
|
|
38
|
-
at object creation time by using a type code, which is a single character.
|
|
39
|
-
The following type codes are defined:
|
|
40
|
-
|
|
41
|
-
Type code C Type Minimum size in bytes
|
|
42
|
-
'b' signed integer 1
|
|
43
|
-
'B' unsigned integer 1
|
|
44
|
-
'u' Unicode character 2 (see note)
|
|
45
|
-
'h' signed integer 2
|
|
46
|
-
'H' unsigned integer 2
|
|
47
|
-
'i' signed integer 2
|
|
48
|
-
'I' unsigned integer 2
|
|
49
|
-
'l' signed integer 4
|
|
50
|
-
'L' unsigned integer 4
|
|
51
|
-
'q' signed integer 8 (see note)
|
|
52
|
-
'Q' unsigned integer 8 (see note)
|
|
53
|
-
'f' floating point 4
|
|
54
|
-
'd' floating point 8
|
|
55
|
-
|
|
56
|
-
NOTE: The 'u' typecode corresponds to Python's unicode character. On
|
|
57
|
-
narrow builds this is 2-bytes on wide builds this is 4-bytes.
|
|
58
|
-
|
|
59
|
-
NOTE: The 'q' and 'Q' type codes are only available if the platform
|
|
60
|
-
C compiler used to build Python supports 'long long', or, on Windows,
|
|
61
|
-
'__int64'.
|
|
62
|
-
|
|
63
|
-
Methods:
|
|
64
|
-
|
|
65
|
-
append() -- append a new item to the end of the array
|
|
66
|
-
buffer_info() -- return information giving the current memory info
|
|
67
|
-
byteswap() -- byteswap all the items of the array
|
|
68
|
-
count() -- return number of occurrences of an object
|
|
69
|
-
extend() -- extend array by appending multiple elements from an iterable
|
|
70
|
-
fromfile() -- read items from a file object
|
|
71
|
-
fromlist() -- append items from the list
|
|
72
|
-
frombytes() -- append items from the string
|
|
73
|
-
index() -- return index of first occurrence of an object
|
|
74
|
-
insert() -- insert a new item into the array at a provided position
|
|
75
|
-
pop() -- remove and return item (default last)
|
|
76
|
-
remove() -- remove first occurrence of an object
|
|
77
|
-
reverse() -- reverse the order of the items in the array
|
|
78
|
-
tofile() -- write all items to a file object
|
|
79
|
-
tolist() -- return the array converted to an ordinary list
|
|
80
|
-
tobytes() -- return the array converted to a string
|
|
81
|
-
|
|
82
|
-
Attributes:
|
|
83
|
-
|
|
84
|
-
typecode -- the typecode character used to create the array
|
|
85
|
-
itemsize -- the length in bytes of one array item
|
|
86
|
-
"""
|
|
87
|
-
@property
|
|
88
|
-
def typecode(self) -> _TypeCode:
|
|
89
|
-
"""the typecode character used to create the array"""
|
|
90
|
-
...
|
|
91
|
-
@property
|
|
92
|
-
def itemsize(self) -> int:
|
|
93
|
-
"""the size, in bytes, of one array item"""
|
|
94
|
-
...
|
|
95
|
-
@overload
|
|
96
|
-
def __init__(self: array[int], typecode: _IntTypeCode, initializer: bytes | bytearray | Iterable[int] = ..., /) -> None: ...
|
|
97
|
-
@overload
|
|
98
|
-
def __init__(
|
|
99
|
-
self: array[float], typecode: _FloatTypeCode, initializer: bytes | bytearray | Iterable[float] = ..., /
|
|
100
|
-
) -> None: ...
|
|
101
|
-
@overload
|
|
102
|
-
def __init__(
|
|
103
|
-
self: array[str], typecode: _UnicodeTypeCode, initializer: bytes | bytearray | Iterable[str] = ..., /
|
|
104
|
-
) -> None: ...
|
|
105
|
-
@overload
|
|
106
|
-
def __init__(self, typecode: str, initializer: Iterable[_T], /) -> None: ...
|
|
107
|
-
@overload
|
|
108
|
-
def __init__(self, typecode: str, initializer: bytes | bytearray = ..., /) -> None: ...
|
|
109
|
-
def append(self, v: _T, /) -> None:
|
|
110
|
-
"""Append new value v to the end of the array."""
|
|
111
|
-
...
|
|
112
|
-
def buffer_info(self) -> tuple[int, int]:
|
|
113
|
-
"""
|
|
114
|
-
Return a tuple (address, length) giving the current memory address and the length in items of the buffer used to hold array's contents.
|
|
115
|
-
|
|
116
|
-
The length should be multiplied by the itemsize attribute to calculate
|
|
117
|
-
the buffer length in bytes.
|
|
118
|
-
"""
|
|
119
|
-
...
|
|
120
|
-
def byteswap(self) -> None:
|
|
121
|
-
"""
|
|
122
|
-
Byteswap all items of the array.
|
|
123
|
-
|
|
124
|
-
If the items in the array are not 1, 2, 4, or 8 bytes in size, RuntimeError is
|
|
125
|
-
raised.
|
|
126
|
-
"""
|
|
127
|
-
...
|
|
128
|
-
def count(self, v: _T, /) -> int:
|
|
129
|
-
"""Return number of occurrences of v in the array."""
|
|
130
|
-
...
|
|
131
|
-
def extend(self, bb: Iterable[_T], /) -> None:
|
|
132
|
-
"""Append items to the end of the array."""
|
|
133
|
-
...
|
|
134
|
-
def frombytes(self, buffer: ReadableBuffer, /) -> None:
|
|
135
|
-
"""Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method)."""
|
|
136
|
-
...
|
|
137
|
-
def fromfile(self, f: SupportsRead[bytes], n: int, /) -> None:
|
|
138
|
-
"""Read n objects from the file object f and append them to the end of the array."""
|
|
139
|
-
...
|
|
140
|
-
def fromlist(self, list: list[_T], /) -> None:
|
|
141
|
-
"""Append items to array from list."""
|
|
142
|
-
...
|
|
143
|
-
def fromunicode(self, ustr: str, /) -> None:
|
|
144
|
-
"""
|
|
145
|
-
Extends this array with data from the unicode string ustr.
|
|
146
|
-
|
|
147
|
-
The array must be a unicode type array; otherwise a ValueError is raised.
|
|
148
|
-
Use array.frombytes(ustr.encode(...)) to append Unicode data to an array of
|
|
149
|
-
some other type.
|
|
150
|
-
"""
|
|
151
|
-
...
|
|
152
|
-
if sys.version_info >= (3, 10):
|
|
153
|
-
def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int:
|
|
154
|
-
"""
|
|
155
|
-
Return index of first occurrence of v in the array.
|
|
156
|
-
|
|
157
|
-
Raise ValueError if the value is not present.
|
|
158
|
-
"""
|
|
159
|
-
...
|
|
160
|
-
else:
|
|
161
|
-
def index(self, v: _T, /) -> int:
|
|
162
|
-
"""Return index of first occurrence of v in the array."""
|
|
163
|
-
...
|
|
164
|
-
|
|
165
|
-
def insert(self, i: int, v: _T, /) -> None:
|
|
166
|
-
"""Insert a new item v into the array before position i."""
|
|
167
|
-
...
|
|
168
|
-
def pop(self, i: int = -1, /) -> _T:
|
|
169
|
-
"""
|
|
170
|
-
Return the i-th element and delete it from the array.
|
|
171
|
-
|
|
172
|
-
i defaults to -1.
|
|
173
|
-
"""
|
|
174
|
-
...
|
|
175
|
-
def remove(self, v: _T, /) -> None:
|
|
176
|
-
"""Remove the first occurrence of v in the array."""
|
|
177
|
-
...
|
|
178
|
-
def tobytes(self) -> bytes:
|
|
179
|
-
"""Convert the array to an array of machine values and return the bytes representation."""
|
|
180
|
-
...
|
|
181
|
-
def tofile(self, f: SupportsWrite[bytes], /) -> None:
|
|
182
|
-
"""Write all items (as machine values) to the file object f."""
|
|
183
|
-
...
|
|
184
|
-
def tolist(self) -> list[_T]:
|
|
185
|
-
"""Convert array to an ordinary list with the same items."""
|
|
186
|
-
...
|
|
187
|
-
def tounicode(self) -> str:
|
|
188
|
-
"""
|
|
189
|
-
Extends this array with data from the unicode string ustr.
|
|
190
|
-
|
|
191
|
-
Convert the array to a unicode string. The array must be a unicode type array;
|
|
192
|
-
otherwise a ValueError is raised. Use array.tobytes().decode() to obtain a
|
|
193
|
-
unicode string from an array of some other type.
|
|
194
|
-
"""
|
|
195
|
-
...
|
|
196
|
-
if sys.version_info < (3, 9):
|
|
197
|
-
def fromstring(self, buffer: str | ReadableBuffer, /) -> None:
|
|
198
|
-
"""
|
|
199
|
-
Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method).
|
|
200
|
-
|
|
201
|
-
This method is deprecated. Use frombytes instead.
|
|
202
|
-
"""
|
|
203
|
-
...
|
|
204
|
-
def tostring(self) -> bytes:
|
|
205
|
-
"""
|
|
206
|
-
Convert the array to an array of machine values and return the bytes representation.
|
|
207
|
-
|
|
208
|
-
This method is deprecated. Use tobytes instead.
|
|
209
|
-
"""
|
|
210
|
-
...
|
|
211
|
-
|
|
212
|
-
def __len__(self) -> int:
|
|
213
|
-
"""Return len(self)."""
|
|
214
|
-
...
|
|
215
|
-
@overload
|
|
216
|
-
def __getitem__(self, key: SupportsIndex, /) -> _T:
|
|
217
|
-
"""Return self[key]."""
|
|
218
|
-
...
|
|
219
|
-
@overload
|
|
220
|
-
def __getitem__(self, key: slice, /) -> array[_T]:
|
|
221
|
-
"""Return self[key]."""
|
|
222
|
-
...
|
|
223
|
-
@overload # type: ignore[override]
|
|
224
|
-
def __setitem__(self, key: SupportsIndex, value: _T, /) -> None:
|
|
225
|
-
"""Set self[key] to value."""
|
|
226
|
-
...
|
|
227
|
-
@overload
|
|
228
|
-
def __setitem__(self, key: slice, value: array[_T], /) -> None:
|
|
229
|
-
"""Set self[key] to value."""
|
|
230
|
-
...
|
|
231
|
-
def __delitem__(self, key: SupportsIndex | slice, /) -> None:
|
|
232
|
-
"""Delete self[key]."""
|
|
233
|
-
...
|
|
234
|
-
def __add__(self, value: array[_T], /) -> array[_T]:
|
|
235
|
-
"""Return self+value."""
|
|
236
|
-
...
|
|
237
|
-
def __eq__(self, value: object, /) -> bool:
|
|
238
|
-
"""Return self==value."""
|
|
239
|
-
...
|
|
240
|
-
def __ge__(self, value: array[_T], /) -> bool:
|
|
241
|
-
"""Return self>=value."""
|
|
242
|
-
...
|
|
243
|
-
def __gt__(self, value: array[_T], /) -> bool:
|
|
244
|
-
"""Return self>value."""
|
|
245
|
-
...
|
|
246
|
-
def __iadd__(self, value: array[_T], /) -> Self:
|
|
247
|
-
"""Implement self+=value."""
|
|
248
|
-
...
|
|
249
|
-
def __imul__(self, value: int, /) -> Self:
|
|
250
|
-
"""Implement self*=value."""
|
|
251
|
-
...
|
|
252
|
-
def __le__(self, value: array[_T], /) -> bool:
|
|
253
|
-
"""Return self<=value."""
|
|
254
|
-
...
|
|
255
|
-
def __lt__(self, value: array[_T], /) -> bool:
|
|
256
|
-
"""Return self<value."""
|
|
257
|
-
...
|
|
258
|
-
def __mul__(self, value: int, /) -> array[_T]:
|
|
259
|
-
"""Return self*value."""
|
|
260
|
-
...
|
|
261
|
-
def __rmul__(self, value: int, /) -> array[_T]:
|
|
262
|
-
"""Return value*self."""
|
|
263
|
-
...
|
|
264
|
-
def __copy__(self) -> array[_T]:
|
|
265
|
-
"""Return a copy of the array."""
|
|
266
|
-
...
|
|
267
|
-
def __deepcopy__(self, unused: Any, /) -> array[_T]:
|
|
268
|
-
"""Return a copy of the array."""
|
|
269
|
-
...
|
|
270
|
-
def __buffer__(self, flags: int, /) -> memoryview:
|
|
271
|
-
"""Return a buffer object that exposes the underlying memory of the object."""
|
|
272
|
-
...
|
|
273
|
-
def __release_buffer__(self, buffer: memoryview, /) -> None:
|
|
274
|
-
"""Release the buffer object that exposes the underlying memory of the object."""
|
|
275
|
-
...
|
|
276
|
-
if sys.version_info >= (3, 12):
|
|
277
|
-
def __class_getitem__(cls, item: Any, /) -> GenericAlias:
|
|
278
|
-
"""See PEP 585"""
|
|
279
|
-
...
|
|
280
|
-
|
|
281
|
-
ArrayType = array
|
|
1
|
+
"""
|
|
2
|
+
This module defines an object type which can efficiently represent
|
|
3
|
+
an array of basic values: characters, integers, floating point
|
|
4
|
+
numbers. Arrays are sequence types and behave very much like lists,
|
|
5
|
+
except that the type of objects stored in them is constrained.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
|
|
10
|
+
from collections.abc import Iterable
|
|
11
|
+
|
|
12
|
+
# pytype crashes if array inherits from collections.abc.MutableSequence instead of typing.MutableSequence
|
|
13
|
+
from typing import Any, Literal, MutableSequence, SupportsIndex, TypeVar, overload # noqa: Y022
|
|
14
|
+
from typing_extensions import Self, TypeAlias
|
|
15
|
+
|
|
16
|
+
if sys.version_info >= (3, 12):
|
|
17
|
+
from types import GenericAlias
|
|
18
|
+
|
|
19
|
+
_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
|
|
20
|
+
_FloatTypeCode: TypeAlias = Literal["f", "d"]
|
|
21
|
+
_UnicodeTypeCode: TypeAlias = Literal["u"]
|
|
22
|
+
_TypeCode: TypeAlias = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode
|
|
23
|
+
|
|
24
|
+
_T = TypeVar("_T", int, float, str)
|
|
25
|
+
|
|
26
|
+
typecodes: str
|
|
27
|
+
|
|
28
|
+
class array(MutableSequence[_T]):
|
|
29
|
+
"""
|
|
30
|
+
array(typecode [, initializer]) -> array
|
|
31
|
+
|
|
32
|
+
Return a new array whose items are restricted by typecode, and
|
|
33
|
+
initialized from the optional initializer value, which must be a list,
|
|
34
|
+
string or iterable over elements of the appropriate type.
|
|
35
|
+
|
|
36
|
+
Arrays represent basic values and behave very much like lists, except
|
|
37
|
+
the type of objects stored in them is constrained. The type is specified
|
|
38
|
+
at object creation time by using a type code, which is a single character.
|
|
39
|
+
The following type codes are defined:
|
|
40
|
+
|
|
41
|
+
Type code C Type Minimum size in bytes
|
|
42
|
+
'b' signed integer 1
|
|
43
|
+
'B' unsigned integer 1
|
|
44
|
+
'u' Unicode character 2 (see note)
|
|
45
|
+
'h' signed integer 2
|
|
46
|
+
'H' unsigned integer 2
|
|
47
|
+
'i' signed integer 2
|
|
48
|
+
'I' unsigned integer 2
|
|
49
|
+
'l' signed integer 4
|
|
50
|
+
'L' unsigned integer 4
|
|
51
|
+
'q' signed integer 8 (see note)
|
|
52
|
+
'Q' unsigned integer 8 (see note)
|
|
53
|
+
'f' floating point 4
|
|
54
|
+
'd' floating point 8
|
|
55
|
+
|
|
56
|
+
NOTE: The 'u' typecode corresponds to Python's unicode character. On
|
|
57
|
+
narrow builds this is 2-bytes on wide builds this is 4-bytes.
|
|
58
|
+
|
|
59
|
+
NOTE: The 'q' and 'Q' type codes are only available if the platform
|
|
60
|
+
C compiler used to build Python supports 'long long', or, on Windows,
|
|
61
|
+
'__int64'.
|
|
62
|
+
|
|
63
|
+
Methods:
|
|
64
|
+
|
|
65
|
+
append() -- append a new item to the end of the array
|
|
66
|
+
buffer_info() -- return information giving the current memory info
|
|
67
|
+
byteswap() -- byteswap all the items of the array
|
|
68
|
+
count() -- return number of occurrences of an object
|
|
69
|
+
extend() -- extend array by appending multiple elements from an iterable
|
|
70
|
+
fromfile() -- read items from a file object
|
|
71
|
+
fromlist() -- append items from the list
|
|
72
|
+
frombytes() -- append items from the string
|
|
73
|
+
index() -- return index of first occurrence of an object
|
|
74
|
+
insert() -- insert a new item into the array at a provided position
|
|
75
|
+
pop() -- remove and return item (default last)
|
|
76
|
+
remove() -- remove first occurrence of an object
|
|
77
|
+
reverse() -- reverse the order of the items in the array
|
|
78
|
+
tofile() -- write all items to a file object
|
|
79
|
+
tolist() -- return the array converted to an ordinary list
|
|
80
|
+
tobytes() -- return the array converted to a string
|
|
81
|
+
|
|
82
|
+
Attributes:
|
|
83
|
+
|
|
84
|
+
typecode -- the typecode character used to create the array
|
|
85
|
+
itemsize -- the length in bytes of one array item
|
|
86
|
+
"""
|
|
87
|
+
@property
|
|
88
|
+
def typecode(self) -> _TypeCode:
|
|
89
|
+
"""the typecode character used to create the array"""
|
|
90
|
+
...
|
|
91
|
+
@property
|
|
92
|
+
def itemsize(self) -> int:
|
|
93
|
+
"""the size, in bytes, of one array item"""
|
|
94
|
+
...
|
|
95
|
+
@overload
|
|
96
|
+
def __init__(self: array[int], typecode: _IntTypeCode, initializer: bytes | bytearray | Iterable[int] = ..., /) -> None: ...
|
|
97
|
+
@overload
|
|
98
|
+
def __init__(
|
|
99
|
+
self: array[float], typecode: _FloatTypeCode, initializer: bytes | bytearray | Iterable[float] = ..., /
|
|
100
|
+
) -> None: ...
|
|
101
|
+
@overload
|
|
102
|
+
def __init__(
|
|
103
|
+
self: array[str], typecode: _UnicodeTypeCode, initializer: bytes | bytearray | Iterable[str] = ..., /
|
|
104
|
+
) -> None: ...
|
|
105
|
+
@overload
|
|
106
|
+
def __init__(self, typecode: str, initializer: Iterable[_T], /) -> None: ...
|
|
107
|
+
@overload
|
|
108
|
+
def __init__(self, typecode: str, initializer: bytes | bytearray = ..., /) -> None: ...
|
|
109
|
+
def append(self, v: _T, /) -> None:
|
|
110
|
+
"""Append new value v to the end of the array."""
|
|
111
|
+
...
|
|
112
|
+
def buffer_info(self) -> tuple[int, int]:
|
|
113
|
+
"""
|
|
114
|
+
Return a tuple (address, length) giving the current memory address and the length in items of the buffer used to hold array's contents.
|
|
115
|
+
|
|
116
|
+
The length should be multiplied by the itemsize attribute to calculate
|
|
117
|
+
the buffer length in bytes.
|
|
118
|
+
"""
|
|
119
|
+
...
|
|
120
|
+
def byteswap(self) -> None:
|
|
121
|
+
"""
|
|
122
|
+
Byteswap all items of the array.
|
|
123
|
+
|
|
124
|
+
If the items in the array are not 1, 2, 4, or 8 bytes in size, RuntimeError is
|
|
125
|
+
raised.
|
|
126
|
+
"""
|
|
127
|
+
...
|
|
128
|
+
def count(self, v: _T, /) -> int:
|
|
129
|
+
"""Return number of occurrences of v in the array."""
|
|
130
|
+
...
|
|
131
|
+
def extend(self, bb: Iterable[_T], /) -> None:
|
|
132
|
+
"""Append items to the end of the array."""
|
|
133
|
+
...
|
|
134
|
+
def frombytes(self, buffer: ReadableBuffer, /) -> None:
|
|
135
|
+
"""Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method)."""
|
|
136
|
+
...
|
|
137
|
+
def fromfile(self, f: SupportsRead[bytes], n: int, /) -> None:
|
|
138
|
+
"""Read n objects from the file object f and append them to the end of the array."""
|
|
139
|
+
...
|
|
140
|
+
def fromlist(self, list: list[_T], /) -> None:
|
|
141
|
+
"""Append items to array from list."""
|
|
142
|
+
...
|
|
143
|
+
def fromunicode(self, ustr: str, /) -> None:
|
|
144
|
+
"""
|
|
145
|
+
Extends this array with data from the unicode string ustr.
|
|
146
|
+
|
|
147
|
+
The array must be a unicode type array; otherwise a ValueError is raised.
|
|
148
|
+
Use array.frombytes(ustr.encode(...)) to append Unicode data to an array of
|
|
149
|
+
some other type.
|
|
150
|
+
"""
|
|
151
|
+
...
|
|
152
|
+
if sys.version_info >= (3, 10):
|
|
153
|
+
def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int:
|
|
154
|
+
"""
|
|
155
|
+
Return index of first occurrence of v in the array.
|
|
156
|
+
|
|
157
|
+
Raise ValueError if the value is not present.
|
|
158
|
+
"""
|
|
159
|
+
...
|
|
160
|
+
else:
|
|
161
|
+
def index(self, v: _T, /) -> int:
|
|
162
|
+
"""Return index of first occurrence of v in the array."""
|
|
163
|
+
...
|
|
164
|
+
|
|
165
|
+
def insert(self, i: int, v: _T, /) -> None:
|
|
166
|
+
"""Insert a new item v into the array before position i."""
|
|
167
|
+
...
|
|
168
|
+
def pop(self, i: int = -1, /) -> _T:
|
|
169
|
+
"""
|
|
170
|
+
Return the i-th element and delete it from the array.
|
|
171
|
+
|
|
172
|
+
i defaults to -1.
|
|
173
|
+
"""
|
|
174
|
+
...
|
|
175
|
+
def remove(self, v: _T, /) -> None:
|
|
176
|
+
"""Remove the first occurrence of v in the array."""
|
|
177
|
+
...
|
|
178
|
+
def tobytes(self) -> bytes:
|
|
179
|
+
"""Convert the array to an array of machine values and return the bytes representation."""
|
|
180
|
+
...
|
|
181
|
+
def tofile(self, f: SupportsWrite[bytes], /) -> None:
|
|
182
|
+
"""Write all items (as machine values) to the file object f."""
|
|
183
|
+
...
|
|
184
|
+
def tolist(self) -> list[_T]:
|
|
185
|
+
"""Convert array to an ordinary list with the same items."""
|
|
186
|
+
...
|
|
187
|
+
def tounicode(self) -> str:
|
|
188
|
+
"""
|
|
189
|
+
Extends this array with data from the unicode string ustr.
|
|
190
|
+
|
|
191
|
+
Convert the array to a unicode string. The array must be a unicode type array;
|
|
192
|
+
otherwise a ValueError is raised. Use array.tobytes().decode() to obtain a
|
|
193
|
+
unicode string from an array of some other type.
|
|
194
|
+
"""
|
|
195
|
+
...
|
|
196
|
+
if sys.version_info < (3, 9):
|
|
197
|
+
def fromstring(self, buffer: str | ReadableBuffer, /) -> None:
|
|
198
|
+
"""
|
|
199
|
+
Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method).
|
|
200
|
+
|
|
201
|
+
This method is deprecated. Use frombytes instead.
|
|
202
|
+
"""
|
|
203
|
+
...
|
|
204
|
+
def tostring(self) -> bytes:
|
|
205
|
+
"""
|
|
206
|
+
Convert the array to an array of machine values and return the bytes representation.
|
|
207
|
+
|
|
208
|
+
This method is deprecated. Use tobytes instead.
|
|
209
|
+
"""
|
|
210
|
+
...
|
|
211
|
+
|
|
212
|
+
def __len__(self) -> int:
|
|
213
|
+
"""Return len(self)."""
|
|
214
|
+
...
|
|
215
|
+
@overload
|
|
216
|
+
def __getitem__(self, key: SupportsIndex, /) -> _T:
|
|
217
|
+
"""Return self[key]."""
|
|
218
|
+
...
|
|
219
|
+
@overload
|
|
220
|
+
def __getitem__(self, key: slice, /) -> array[_T]:
|
|
221
|
+
"""Return self[key]."""
|
|
222
|
+
...
|
|
223
|
+
@overload # type: ignore[override]
|
|
224
|
+
def __setitem__(self, key: SupportsIndex, value: _T, /) -> None:
|
|
225
|
+
"""Set self[key] to value."""
|
|
226
|
+
...
|
|
227
|
+
@overload
|
|
228
|
+
def __setitem__(self, key: slice, value: array[_T], /) -> None:
|
|
229
|
+
"""Set self[key] to value."""
|
|
230
|
+
...
|
|
231
|
+
def __delitem__(self, key: SupportsIndex | slice, /) -> None:
|
|
232
|
+
"""Delete self[key]."""
|
|
233
|
+
...
|
|
234
|
+
def __add__(self, value: array[_T], /) -> array[_T]:
|
|
235
|
+
"""Return self+value."""
|
|
236
|
+
...
|
|
237
|
+
def __eq__(self, value: object, /) -> bool:
|
|
238
|
+
"""Return self==value."""
|
|
239
|
+
...
|
|
240
|
+
def __ge__(self, value: array[_T], /) -> bool:
|
|
241
|
+
"""Return self>=value."""
|
|
242
|
+
...
|
|
243
|
+
def __gt__(self, value: array[_T], /) -> bool:
|
|
244
|
+
"""Return self>value."""
|
|
245
|
+
...
|
|
246
|
+
def __iadd__(self, value: array[_T], /) -> Self:
|
|
247
|
+
"""Implement self+=value."""
|
|
248
|
+
...
|
|
249
|
+
def __imul__(self, value: int, /) -> Self:
|
|
250
|
+
"""Implement self*=value."""
|
|
251
|
+
...
|
|
252
|
+
def __le__(self, value: array[_T], /) -> bool:
|
|
253
|
+
"""Return self<=value."""
|
|
254
|
+
...
|
|
255
|
+
def __lt__(self, value: array[_T], /) -> bool:
|
|
256
|
+
"""Return self<value."""
|
|
257
|
+
...
|
|
258
|
+
def __mul__(self, value: int, /) -> array[_T]:
|
|
259
|
+
"""Return self*value."""
|
|
260
|
+
...
|
|
261
|
+
def __rmul__(self, value: int, /) -> array[_T]:
|
|
262
|
+
"""Return value*self."""
|
|
263
|
+
...
|
|
264
|
+
def __copy__(self) -> array[_T]:
|
|
265
|
+
"""Return a copy of the array."""
|
|
266
|
+
...
|
|
267
|
+
def __deepcopy__(self, unused: Any, /) -> array[_T]:
|
|
268
|
+
"""Return a copy of the array."""
|
|
269
|
+
...
|
|
270
|
+
def __buffer__(self, flags: int, /) -> memoryview:
|
|
271
|
+
"""Return a buffer object that exposes the underlying memory of the object."""
|
|
272
|
+
...
|
|
273
|
+
def __release_buffer__(self, buffer: memoryview, /) -> None:
|
|
274
|
+
"""Release the buffer object that exposes the underlying memory of the object."""
|
|
275
|
+
...
|
|
276
|
+
if sys.version_info >= (3, 12):
|
|
277
|
+
def __class_getitem__(cls, item: Any, /) -> GenericAlias:
|
|
278
|
+
"""See PEP 585"""
|
|
279
|
+
...
|
|
280
|
+
|
|
281
|
+
ArrayType = array
|