basedpyright 1.13.2 → 1.13.3
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 +2 -0
- package/dist/typeshed-fallback/stdlib/_ast.pyi +42 -279
- package/dist/typeshed-fallback/stdlib/_bisect.pyi +221 -221
- package/dist/typeshed-fallback/stdlib/_bootlocale.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/_collections_abc.pyi +15 -5
- package/dist/typeshed-fallback/stdlib/_csv.pyi +213 -213
- package/dist/typeshed-fallback/stdlib/_decimal.pyi +0 -18
- package/dist/typeshed-fallback/stdlib/_dummy_thread.pyi +33 -33
- package/dist/typeshed-fallback/stdlib/_dummy_threading.pyi +180 -164
- package/dist/typeshed-fallback/stdlib/_heapq.pyi +67 -67
- package/dist/typeshed-fallback/stdlib/_interpqueues.pyi +16 -0
- package/dist/typeshed-fallback/stdlib/_interpreters.pyi +50 -0
- package/dist/typeshed-fallback/stdlib/_json.pyi +92 -92
- package/dist/typeshed-fallback/stdlib/_lsprof.pyi +92 -92
- package/dist/typeshed-fallback/stdlib/_msi.pyi +94 -92
- package/dist/typeshed-fallback/stdlib/_operator.pyi +0 -24
- package/dist/typeshed-fallback/stdlib/_random.pyi +30 -30
- package/dist/typeshed-fallback/stdlib/_tkinter.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/_weakrefset.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/abc.pyi +12 -4
- package/dist/typeshed-fallback/stdlib/argparse.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/array.pyi +281 -281
- package/dist/typeshed-fallback/stdlib/asynchat.pyi +21 -21
- package/dist/typeshed-fallback/stdlib/asyncio/events.pyi +35 -4
- package/dist/typeshed-fallback/stdlib/asyncio/futures.pyi +107 -15
- package/dist/typeshed-fallback/stdlib/asyncio/locks.pyi +9 -3
- package/dist/typeshed-fallback/stdlib/asyncio/queues.pyi +10 -2
- package/dist/typeshed-fallback/stdlib/asyncio/sslproto.pyi +23 -4
- package/dist/typeshed-fallback/stdlib/asyncio/tasks.pyi +107 -12
- package/dist/typeshed-fallback/stdlib/asyncio/windows_events.pyi +86 -86
- package/dist/typeshed-fallback/stdlib/asyncio/windows_utils.pyi +49 -49
- package/dist/typeshed-fallback/stdlib/asyncore.pyi +90 -90
- package/dist/typeshed-fallback/stdlib/audioop.pyi +95 -95
- package/dist/typeshed-fallback/stdlib/binascii.pyi +123 -123
- package/dist/typeshed-fallback/stdlib/binhex.pyi +45 -45
- package/dist/typeshed-fallback/stdlib/builtins.pyi +0 -1
- package/dist/typeshed-fallback/stdlib/bz2.pyi +59 -6
- package/dist/typeshed-fallback/stdlib/cmath.pyi +112 -112
- package/dist/typeshed-fallback/stdlib/codecs.pyi +18 -6
- package/dist/typeshed-fallback/stdlib/collections/__init__.pyi +200 -56
- package/dist/typeshed-fallback/stdlib/concurrent/futures/__init__.pyi +33 -14
- package/dist/typeshed-fallback/stdlib/concurrent/futures/_base.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/concurrent/futures/thread.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/contextvars.pyi +99 -16
- package/dist/typeshed-fallback/stdlib/csv.pyi +14 -2
- package/dist/typeshed-fallback/stdlib/ctypes/__init__.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/ctypes/_endian.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/curses/panel.pyi +16 -4
- package/dist/typeshed-fallback/stdlib/dataclasses.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/datetime.pyi +346 -104
- package/dist/typeshed-fallback/stdlib/dbm/gnu.pyi +52 -2
- package/dist/typeshed-fallback/stdlib/dbm/ndbm.pyi +26 -2
- package/dist/typeshed-fallback/stdlib/difflib.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/distutils/__init__.pyi +5 -5
- package/dist/typeshed-fallback/stdlib/distutils/archive_util.pyi +35 -35
- package/dist/typeshed-fallback/stdlib/distutils/bcppcompiler.pyi +3 -3
- package/dist/typeshed-fallback/stdlib/distutils/ccompiler.pyi +173 -173
- package/dist/typeshed-fallback/stdlib/distutils/cmd.pyi +99 -99
- package/dist/typeshed-fallback/stdlib/distutils/command/bdist.pyi +25 -25
- package/dist/typeshed-fallback/stdlib/distutils/command/bdist_dumb.pyi +21 -21
- package/dist/typeshed-fallback/stdlib/distutils/command/bdist_msi.pyi +45 -45
- package/dist/typeshed-fallback/stdlib/distutils/command/bdist_rpm.pyi +52 -52
- package/dist/typeshed-fallback/stdlib/distutils/command/bdist_wininst.pyi +16 -16
- package/dist/typeshed-fallback/stdlib/distutils/command/build.pyi +33 -33
- package/dist/typeshed-fallback/stdlib/distutils/command/build_clib.pyi +27 -27
- package/dist/typeshed-fallback/stdlib/distutils/command/build_ext.pyi +50 -50
- package/dist/typeshed-fallback/stdlib/distutils/command/build_py.pyi +44 -44
- package/dist/typeshed-fallback/stdlib/distutils/command/build_scripts.pyi +24 -24
- package/dist/typeshed-fallback/stdlib/distutils/command/check.pyi +39 -39
- package/dist/typeshed-fallback/stdlib/distutils/command/clean.pyi +17 -17
- package/dist/typeshed-fallback/stdlib/distutils/command/config.pyi +84 -84
- package/dist/typeshed-fallback/stdlib/distutils/command/install.pyi +65 -65
- package/dist/typeshed-fallback/stdlib/distutils/command/install_data.pyi +19 -19
- package/dist/typeshed-fallback/stdlib/distutils/command/install_egg_info.pyi +18 -18
- package/dist/typeshed-fallback/stdlib/distutils/command/install_headers.pyi +16 -16
- package/dist/typeshed-fallback/stdlib/distutils/command/install_lib.pyi +25 -25
- package/dist/typeshed-fallback/stdlib/distutils/command/install_scripts.pyi +18 -18
- package/dist/typeshed-fallback/stdlib/distutils/command/register.pyi +20 -20
- package/dist/typeshed-fallback/stdlib/distutils/command/sdist.pyi +44 -44
- package/dist/typeshed-fallback/stdlib/distutils/command/upload.pyi +17 -17
- package/dist/typeshed-fallback/stdlib/distutils/config.pyi +17 -17
- package/dist/typeshed-fallback/stdlib/distutils/core.pyi +57 -57
- package/dist/typeshed-fallback/stdlib/distutils/cygwinccompiler.pyi +20 -20
- package/dist/typeshed-fallback/stdlib/distutils/debug.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/distutils/dep_util.pyi +14 -14
- package/dist/typeshed-fallback/stdlib/distutils/dir_util.pyi +23 -23
- package/dist/typeshed-fallback/stdlib/distutils/dist.pyi +149 -149
- package/dist/typeshed-fallback/stdlib/distutils/errors.pyi +19 -19
- package/dist/typeshed-fallback/stdlib/distutils/extension.pyi +36 -36
- package/dist/typeshed-fallback/stdlib/distutils/fancy_getopt.pyi +34 -34
- package/dist/typeshed-fallback/stdlib/distutils/file_util.pyi +38 -38
- package/dist/typeshed-fallback/stdlib/distutils/filelist.pyi +58 -58
- package/dist/typeshed-fallback/stdlib/distutils/log.pyi +25 -25
- package/dist/typeshed-fallback/stdlib/distutils/msvccompiler.pyi +3 -3
- package/dist/typeshed-fallback/stdlib/distutils/spawn.pyi +6 -6
- package/dist/typeshed-fallback/stdlib/distutils/sysconfig.pyi +33 -33
- package/dist/typeshed-fallback/stdlib/distutils/text_file.pyi +21 -21
- package/dist/typeshed-fallback/stdlib/distutils/unixccompiler.pyi +3 -3
- package/dist/typeshed-fallback/stdlib/distutils/util.pyi +50 -50
- package/dist/typeshed-fallback/stdlib/distutils/version.pyi +38 -36
- package/dist/typeshed-fallback/stdlib/dummy_threading.pyi +2 -2
- package/dist/typeshed-fallback/stdlib/email/_header_value_parser.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/email/charset.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/email/header.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/email/headerregistry.pyi +6 -1
- package/dist/typeshed-fallback/stdlib/enum.pyi +8 -1
- package/dist/typeshed-fallback/stdlib/filecmp.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/fileinput.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/formatter.pyi +88 -88
- package/dist/typeshed-fallback/stdlib/fractions.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/functools.pyi +65 -13
- package/dist/typeshed-fallback/stdlib/graphlib.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/gzip.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/hashlib.pyi +42 -14
- package/dist/typeshed-fallback/stdlib/heapq.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/hmac.pyi +30 -2
- package/dist/typeshed-fallback/stdlib/http/cookies.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/imp.pyi +62 -62
- package/dist/typeshed-fallback/stdlib/importlib/abc.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/importlib/machinery.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/importlib/metadata/__init__.pyi +79 -15
- package/dist/typeshed-fallback/stdlib/importlib/metadata/_meta.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/importlib/resources/simple.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/io.pyi +428 -44
- package/dist/typeshed-fallback/stdlib/ipaddress.pyi +153 -28
- package/dist/typeshed-fallback/stdlib/itertools.pyi +5 -1
- package/dist/typeshed-fallback/stdlib/json/encoder.pyi +14 -2
- package/dist/typeshed-fallback/stdlib/keyword.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/lib2to3/pytree.pyi +12 -2
- package/dist/typeshed-fallback/stdlib/logging/__init__.pyi +17 -3
- package/dist/typeshed-fallback/stdlib/lzma.pyi +107 -9
- package/dist/typeshed-fallback/stdlib/mailbox.pyi +14 -2
- package/dist/typeshed-fallback/stdlib/math.pyi +424 -424
- package/dist/typeshed-fallback/stdlib/mmap.pyi +160 -160
- package/dist/typeshed-fallback/stdlib/msilib/__init__.pyi +177 -177
- package/dist/typeshed-fallback/stdlib/msilib/schema.pyi +94 -94
- package/dist/typeshed-fallback/stdlib/msilib/sequence.pyi +13 -13
- package/dist/typeshed-fallback/stdlib/msilib/text.pyi +7 -7
- package/dist/typeshed-fallback/stdlib/multiprocessing/connection.pyi +9 -3
- package/dist/typeshed-fallback/stdlib/multiprocessing/context.pyi +12 -2
- package/dist/typeshed-fallback/stdlib/multiprocessing/dummy/__init__.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/multiprocessing/managers.pyi +10 -2
- package/dist/typeshed-fallback/stdlib/multiprocessing/pool.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/multiprocessing/popen_spawn_win32.pyi +30 -30
- package/dist/typeshed-fallback/stdlib/multiprocessing/process.pyi +15 -4
- package/dist/typeshed-fallback/stdlib/multiprocessing/queues.pyi +14 -2
- package/dist/typeshed-fallback/stdlib/multiprocessing/shared_memory.pyi +19 -5
- package/dist/typeshed-fallback/stdlib/nis.pyi +31 -4
- package/dist/typeshed-fallback/stdlib/numbers.pyi +26 -6
- package/dist/typeshed-fallback/stdlib/opcode.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/optparse.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/os/__init__.pyi +1447 -217
- package/dist/typeshed-fallback/stdlib/pathlib.pyi +42 -11
- package/dist/typeshed-fallback/stdlib/pickle.pyi +200 -12
- package/dist/typeshed-fallback/stdlib/posixpath.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/pyexpat/errors.pyi +2 -0
- package/dist/typeshed-fallback/stdlib/pyexpat/model.pyi +2 -0
- package/dist/typeshed-fallback/stdlib/queue.pyi +57 -9
- package/dist/typeshed-fallback/stdlib/re.pyi +219 -57
- package/dist/typeshed-fallback/stdlib/sched.pyi +8 -1
- package/dist/typeshed-fallback/stdlib/signal.pyi +95 -19
- package/dist/typeshed-fallback/stdlib/smtpd.pyi +91 -91
- package/dist/typeshed-fallback/stdlib/socket.pyi +12 -2
- package/dist/typeshed-fallback/stdlib/sqlite3/dbapi2.pyi +417 -83
- package/dist/typeshed-fallback/stdlib/ssl.pyi +133 -22
- package/dist/typeshed-fallback/stdlib/statistics.pyi +20 -5
- package/dist/typeshed-fallback/stdlib/struct.pyi +114 -13
- package/dist/typeshed-fallback/stdlib/subprocess.pyi +14 -2
- package/dist/typeshed-fallback/stdlib/symbol.pyi +93 -93
- package/dist/typeshed-fallback/stdlib/symtable.pyi +30 -1
- package/dist/typeshed-fallback/stdlib/sys/__init__.pyi +7 -3
- package/dist/typeshed-fallback/stdlib/tarfile.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/tempfile.pyi +17 -3
- package/dist/typeshed-fallback/stdlib/threading.pyi +68 -7
- package/dist/typeshed-fallback/stdlib/tkinter/__init__.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/turtle.pyi +11 -3
- package/dist/typeshed-fallback/stdlib/types.pyi +306 -79
- package/dist/typeshed-fallback/stdlib/typing.pyi +310 -31
- package/dist/typeshed-fallback/stdlib/typing_extensions.pyi +42 -11
- package/dist/typeshed-fallback/stdlib/unittest/__init__.pyi +6 -1
- package/dist/typeshed-fallback/stdlib/unittest/case.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/unittest/mock.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/urllib/parse.pyi +51 -3
- package/dist/typeshed-fallback/stdlib/weakref.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/winsound.pyi +44 -28
- package/dist/typeshed-fallback/stdlib/xml/dom/minicompat.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/xml/dom/minidom.pyi +33 -11
- package/dist/typeshed-fallback/stdlib/xml/etree/ElementTree.pyi +30 -10
- package/dist/typeshed-fallback/stdlib/xml/parsers/expat/errors.pyi +2 -0
- package/dist/typeshed-fallback/stdlib/xml/parsers/expat/model.pyi +2 -0
- package/dist/typeshed-fallback/stdlib/xxlimited.pyi +19 -4
- package/dist/typeshed-fallback/stdlib/zipimport.pyi +31 -0
- package/dist/typeshed-fallback/stdlib/zlib.pyi +157 -157
- package/dist/typeshed-fallback/stdlib/zoneinfo/__init__.pyi +18 -6
- package/dist/typeshed-fallback/stubs/assertpy/assertpy/extracting.pyi +2 -2
- package/dist/typeshed-fallback/stubs/docker/docker/_types.pyi +18 -1
- package/dist/typeshed-fallback/stubs/docker/docker/api/container.pyi +5 -19
- package/dist/typeshed-fallback/stubs/docker/docker/api/daemon.pyi +2 -1
- package/dist/typeshed-fallback/stubs/docker/docker/models/containers.pyi +268 -6
- package/dist/typeshed-fallback/stubs/docker/docker/types/containers.pyi +3 -7
- package/dist/typeshed-fallback/stubs/docker/docker/types/daemon.pyi +10 -4
- package/dist/typeshed-fallback/stubs/docutils/docutils/parsers/rst/states.pyi +47 -0
- package/dist/typeshed-fallback/stubs/gdb/gdb/__init__.pyi +1 -1
- package/dist/typeshed-fallback/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +1 -1
- package/dist/typeshed-fallback/stubs/openpyxl/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/packaging/extended.pyi +0 -2
- package/dist/typeshed-fallback/stubs/openpyxl/openpyxl/styles/named_styles.pyi +2 -1
- package/dist/typeshed-fallback/stubs/pygit2/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/pytest-lazy-fixture/pytest_lazyfixture.pyi +2 -2
- package/dist/typeshed-fallback/stubs/python-crontab/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/reportlab/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/reportlab/reportlab/lib/rl_safe_eval.pyi +23 -11
- package/dist/typeshed-fallback/stubs/reportlab/reportlab/pdfbase/pdfdoc.pyi +6 -0
- package/dist/typeshed-fallback/stubs/setuptools/METADATA.toml +1 -1
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/_distutils/archive_util.pyi +8 -8
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/_distutils/ccompiler.pyi +11 -17
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/_distutils/cmd.pyi +11 -11
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/_distutils/command/build_py.pyi +1 -2
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/_distutils/filelist.pyi +4 -12
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/_distutils/sysconfig.pyi +2 -4
- package/dist/typeshed-fallback/stubs/setuptools/setuptools/_distutils/util.pyi +5 -8
- package/dist/typeshed-fallback/stubs/str2bool/METADATA.toml +2 -0
- package/dist/typeshed-fallback/stubs/str2bool/str2bool/__init__.pyi +7 -0
- package/package.json +1 -1
|
@@ -44,55 +44,218 @@ SEEK_END: Literal[2]
|
|
|
44
44
|
|
|
45
45
|
open = builtins.open
|
|
46
46
|
|
|
47
|
-
def open_code(path: str) -> IO[bytes]:
|
|
47
|
+
def open_code(path: str) -> IO[bytes]:
|
|
48
|
+
"""
|
|
49
|
+
Opens the provided file with the intent to import the contents.
|
|
50
|
+
|
|
51
|
+
This may perform extra validation beyond open(), but is otherwise interchangeable
|
|
52
|
+
with calling open(path, 'rb').
|
|
53
|
+
"""
|
|
54
|
+
...
|
|
48
55
|
|
|
49
56
|
BlockingIOError = builtins.BlockingIOError
|
|
50
57
|
|
|
51
58
|
class UnsupportedOperation(OSError, ValueError): ...
|
|
52
59
|
|
|
53
60
|
class IOBase(metaclass=abc.ABCMeta):
|
|
54
|
-
def __iter__(self) -> Iterator[bytes]:
|
|
55
|
-
|
|
61
|
+
def __iter__(self) -> Iterator[bytes]:
|
|
62
|
+
"""Implement iter(self)."""
|
|
63
|
+
...
|
|
64
|
+
def __next__(self) -> bytes:
|
|
65
|
+
"""Implement next(self)."""
|
|
66
|
+
...
|
|
56
67
|
def __enter__(self) -> Self: ...
|
|
57
68
|
def __exit__(
|
|
58
69
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
|
59
70
|
) -> None: ...
|
|
60
|
-
def close(self) -> None:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
def close(self) -> None:
|
|
72
|
+
"""
|
|
73
|
+
Flush and close the IO object.
|
|
74
|
+
|
|
75
|
+
This method has no effect if the file is already closed.
|
|
76
|
+
"""
|
|
77
|
+
...
|
|
78
|
+
def fileno(self) -> int:
|
|
79
|
+
"""
|
|
80
|
+
Returns underlying file descriptor if one exists.
|
|
81
|
+
|
|
82
|
+
OSError is raised if the IO object does not use a file descriptor.
|
|
83
|
+
"""
|
|
84
|
+
...
|
|
85
|
+
def flush(self) -> None:
|
|
86
|
+
"""
|
|
87
|
+
Flush write buffers, if applicable.
|
|
88
|
+
|
|
89
|
+
This is not implemented for read-only and non-blocking streams.
|
|
90
|
+
"""
|
|
91
|
+
...
|
|
92
|
+
def isatty(self) -> bool:
|
|
93
|
+
"""
|
|
94
|
+
Return whether this is an 'interactive' stream.
|
|
95
|
+
|
|
96
|
+
Return False if it can't be determined.
|
|
97
|
+
"""
|
|
98
|
+
...
|
|
99
|
+
def readable(self) -> bool:
|
|
100
|
+
"""
|
|
101
|
+
Return whether object was opened for reading.
|
|
102
|
+
|
|
103
|
+
If False, read() will raise OSError.
|
|
104
|
+
"""
|
|
105
|
+
...
|
|
65
106
|
read: Callable[..., Any]
|
|
66
|
-
def readlines(self, hint: int = -1, /) -> list[bytes]:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
107
|
+
def readlines(self, hint: int = -1, /) -> list[bytes]:
|
|
108
|
+
"""
|
|
109
|
+
Return a list of lines from the stream.
|
|
110
|
+
|
|
111
|
+
hint can be specified to control the number of lines read: no more
|
|
112
|
+
lines will be read if the total size (in bytes/characters) of all
|
|
113
|
+
lines so far exceeds hint.
|
|
114
|
+
"""
|
|
115
|
+
...
|
|
116
|
+
def seek(self, offset: int, whence: int = ..., /) -> int:
|
|
117
|
+
"""
|
|
118
|
+
Change stream position.
|
|
119
|
+
|
|
120
|
+
Change the stream position to the given byte offset. The offset is
|
|
121
|
+
interpreted relative to the position indicated by whence. Values
|
|
122
|
+
for whence are:
|
|
123
|
+
|
|
124
|
+
* 0 -- start of stream (the default); offset should be zero or positive
|
|
125
|
+
* 1 -- current stream position; offset may be negative
|
|
126
|
+
* 2 -- end of stream; offset is usually negative
|
|
127
|
+
|
|
128
|
+
Return the new absolute position.
|
|
129
|
+
"""
|
|
130
|
+
...
|
|
131
|
+
def seekable(self) -> bool:
|
|
132
|
+
"""
|
|
133
|
+
Return whether object supports random access.
|
|
134
|
+
|
|
135
|
+
If False, seek(), tell() and truncate() will raise OSError.
|
|
136
|
+
This method may need to do a test seek().
|
|
137
|
+
"""
|
|
138
|
+
...
|
|
139
|
+
def tell(self) -> int:
|
|
140
|
+
"""Return current stream position."""
|
|
141
|
+
...
|
|
142
|
+
def truncate(self, size: int | None = ..., /) -> int:
|
|
143
|
+
"""
|
|
144
|
+
Truncate file to size bytes.
|
|
145
|
+
|
|
146
|
+
File pointer is left unchanged. Size defaults to the current IO
|
|
147
|
+
position as reported by tell(). Returns the new size.
|
|
148
|
+
"""
|
|
149
|
+
...
|
|
150
|
+
def writable(self) -> bool:
|
|
151
|
+
"""
|
|
152
|
+
Return whether object was opened for writing.
|
|
153
|
+
|
|
154
|
+
If False, write() will raise OSError.
|
|
155
|
+
"""
|
|
156
|
+
...
|
|
72
157
|
write: Callable[..., Any]
|
|
73
|
-
def writelines(self, lines: Iterable[ReadableBuffer], /) -> None:
|
|
74
|
-
|
|
158
|
+
def writelines(self, lines: Iterable[ReadableBuffer], /) -> None:
|
|
159
|
+
"""
|
|
160
|
+
Write a list of lines to stream.
|
|
161
|
+
|
|
162
|
+
Line separators are not added, so it is usual for each of the
|
|
163
|
+
lines provided to have a line separator at the end.
|
|
164
|
+
"""
|
|
165
|
+
...
|
|
166
|
+
def readline(self, size: int | None = -1, /) -> bytes:
|
|
167
|
+
r"""
|
|
168
|
+
Read and return a line from the stream.
|
|
169
|
+
|
|
170
|
+
If size is specified, at most size bytes will be read.
|
|
171
|
+
|
|
172
|
+
The line terminator is always b'\n' for binary files; for text
|
|
173
|
+
files, the newlines argument to open can be used to select the line
|
|
174
|
+
terminator(s) recognized.
|
|
175
|
+
"""
|
|
176
|
+
...
|
|
75
177
|
def __del__(self) -> None: ...
|
|
76
178
|
@property
|
|
77
179
|
def closed(self) -> bool: ...
|
|
78
180
|
def _checkClosed(self) -> None: ... # undocumented
|
|
79
181
|
|
|
80
182
|
class RawIOBase(IOBase):
|
|
81
|
-
def readall(self) -> bytes:
|
|
183
|
+
def readall(self) -> bytes:
|
|
184
|
+
"""Read until EOF, using multiple read() call."""
|
|
185
|
+
...
|
|
82
186
|
def readinto(self, buffer: WriteableBuffer, /) -> int | None: ...
|
|
83
187
|
def write(self, b: ReadableBuffer, /) -> int | None: ...
|
|
84
188
|
def read(self, size: int = -1, /) -> bytes | None: ...
|
|
85
189
|
|
|
86
190
|
class BufferedIOBase(IOBase):
|
|
87
191
|
raw: RawIOBase # This is not part of the BufferedIOBase API and may not exist on some implementations.
|
|
88
|
-
def detach(self) -> RawIOBase:
|
|
192
|
+
def detach(self) -> RawIOBase:
|
|
193
|
+
"""
|
|
194
|
+
Disconnect this buffer from its underlying raw stream and return it.
|
|
195
|
+
|
|
196
|
+
After the raw stream has been detached, the buffer is in an unusable
|
|
197
|
+
state.
|
|
198
|
+
"""
|
|
199
|
+
...
|
|
89
200
|
def readinto(self, buffer: WriteableBuffer, /) -> int: ...
|
|
90
|
-
def write(self, buffer: ReadableBuffer, /) -> int:
|
|
201
|
+
def write(self, buffer: ReadableBuffer, /) -> int:
|
|
202
|
+
"""
|
|
203
|
+
Write the given buffer to the IO stream.
|
|
204
|
+
|
|
205
|
+
Returns the number of bytes written, which is always the length of b
|
|
206
|
+
in bytes.
|
|
207
|
+
|
|
208
|
+
Raises BlockingIOError if the buffer is full and the
|
|
209
|
+
underlying raw stream cannot accept more data at the moment.
|
|
210
|
+
"""
|
|
211
|
+
...
|
|
91
212
|
def readinto1(self, buffer: WriteableBuffer, /) -> int: ...
|
|
92
|
-
def read(self, size: int | None = ..., /) -> bytes:
|
|
93
|
-
|
|
213
|
+
def read(self, size: int | None = ..., /) -> bytes:
|
|
214
|
+
"""
|
|
215
|
+
Read and return up to n bytes.
|
|
216
|
+
|
|
217
|
+
If the argument is omitted, None, or negative, reads and
|
|
218
|
+
returns all data until EOF.
|
|
219
|
+
|
|
220
|
+
If the argument is positive, and the underlying raw stream is
|
|
221
|
+
not 'interactive', multiple raw reads may be issued to satisfy
|
|
222
|
+
the byte count (unless EOF is reached first). But for
|
|
223
|
+
interactive raw streams (as well as sockets and pipes), at most
|
|
224
|
+
one raw read will be issued, and a short result does not imply
|
|
225
|
+
that EOF is imminent.
|
|
226
|
+
|
|
227
|
+
Returns an empty bytes object on EOF.
|
|
228
|
+
|
|
229
|
+
Returns None if the underlying raw stream was open in non-blocking
|
|
230
|
+
mode and no data is available at the moment.
|
|
231
|
+
"""
|
|
232
|
+
...
|
|
233
|
+
def read1(self, size: int = ..., /) -> bytes:
|
|
234
|
+
"""
|
|
235
|
+
Read and return up to n bytes, with at most one read() call
|
|
236
|
+
to the underlying raw stream. A short result does not imply
|
|
237
|
+
that EOF is imminent.
|
|
238
|
+
|
|
239
|
+
Returns an empty bytes object on EOF.
|
|
240
|
+
"""
|
|
241
|
+
...
|
|
94
242
|
|
|
95
243
|
class FileIO(RawIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
|
|
244
|
+
"""
|
|
245
|
+
Open a file.
|
|
246
|
+
|
|
247
|
+
The mode can be 'r' (default), 'w', 'x' or 'a' for reading,
|
|
248
|
+
writing, exclusive creation or appending. The file will be created if it
|
|
249
|
+
doesn't exist when opened for writing or appending; it will be truncated
|
|
250
|
+
when opened for writing. A FileExistsError will be raised if it already
|
|
251
|
+
exists when opened for creating. Opening a file for creating implies
|
|
252
|
+
writing so this mode behaves in a similar way to 'w'.Add a '+' to the mode
|
|
253
|
+
to allow simultaneous reading and writing. A custom opener can be used by
|
|
254
|
+
passing a callable as *opener*. The underlying file descriptor for the file
|
|
255
|
+
object is then obtained by calling opener with (*name*, *flags*).
|
|
256
|
+
*opener* must return an open file descriptor (passing os.open as *opener*
|
|
257
|
+
results in functionality similar to passing None).
|
|
258
|
+
"""
|
|
96
259
|
mode: str
|
|
97
260
|
# The type of "name" equals the argument passed in to the constructor,
|
|
98
261
|
# but that can make FileIO incompatible with other I/O types that assume
|
|
@@ -102,37 +265,93 @@ class FileIO(RawIOBase, BinaryIO): # type: ignore[misc] # incompatible definit
|
|
|
102
265
|
self, file: FileDescriptorOrPath, mode: str = ..., closefd: bool = ..., opener: _Opener | None = ...
|
|
103
266
|
) -> None: ...
|
|
104
267
|
@property
|
|
105
|
-
def closefd(self) -> bool:
|
|
106
|
-
|
|
107
|
-
|
|
268
|
+
def closefd(self) -> bool:
|
|
269
|
+
"""True if the file descriptor will be closed by close()."""
|
|
270
|
+
...
|
|
271
|
+
def write(self, b: ReadableBuffer, /) -> int:
|
|
272
|
+
"""
|
|
273
|
+
Write buffer b to file, return number of bytes written.
|
|
274
|
+
|
|
275
|
+
Only makes one system call, so not all of the data may be written.
|
|
276
|
+
The number of bytes actually written is returned. In non-blocking mode,
|
|
277
|
+
returns None if the write would block.
|
|
278
|
+
"""
|
|
279
|
+
...
|
|
280
|
+
def read(self, size: int = -1, /) -> bytes:
|
|
281
|
+
"""
|
|
282
|
+
Read at most size bytes, returned as bytes.
|
|
283
|
+
|
|
284
|
+
Only makes one system call, so less data may be returned than requested.
|
|
285
|
+
In non-blocking mode, returns None if no data is available.
|
|
286
|
+
Return an empty bytes object at EOF.
|
|
287
|
+
"""
|
|
288
|
+
...
|
|
108
289
|
def __enter__(self) -> Self: ...
|
|
109
290
|
|
|
110
291
|
class BytesIO(BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes
|
|
292
|
+
"""Buffered I/O implementation using an in-memory bytes buffer."""
|
|
111
293
|
def __init__(self, initial_bytes: ReadableBuffer = ...) -> None: ...
|
|
112
294
|
# BytesIO does not contain a "name" field. This workaround is necessary
|
|
113
295
|
# to allow BytesIO sub-classes to add this field, as it is defined
|
|
114
296
|
# as a read-only property on IO[].
|
|
115
297
|
name: Any
|
|
116
298
|
def __enter__(self) -> Self: ...
|
|
117
|
-
def getvalue(self) -> bytes:
|
|
118
|
-
|
|
119
|
-
|
|
299
|
+
def getvalue(self) -> bytes:
|
|
300
|
+
"""Retrieve the entire contents of the BytesIO object."""
|
|
301
|
+
...
|
|
302
|
+
def getbuffer(self) -> memoryview:
|
|
303
|
+
"""Get a read-write view over the contents of the BytesIO object."""
|
|
304
|
+
...
|
|
305
|
+
def read1(self, size: int | None = -1, /) -> bytes:
|
|
306
|
+
"""
|
|
307
|
+
Read at most size bytes, returned as a bytes object.
|
|
308
|
+
|
|
309
|
+
If the size argument is negative or omitted, read until EOF is reached.
|
|
310
|
+
Return an empty bytes object at EOF.
|
|
311
|
+
"""
|
|
312
|
+
...
|
|
120
313
|
|
|
121
314
|
class BufferedReader(BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes
|
|
315
|
+
"""Create a new buffered reader using the given readable raw IO object."""
|
|
122
316
|
def __enter__(self) -> Self: ...
|
|
123
317
|
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
|
|
124
318
|
def peek(self, size: int = 0, /) -> bytes: ...
|
|
125
319
|
|
|
126
320
|
class BufferedWriter(BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
|
|
321
|
+
"""
|
|
322
|
+
A buffer for a writeable sequential RawIO object.
|
|
323
|
+
|
|
324
|
+
The constructor creates a BufferedWriter for the given writeable raw
|
|
325
|
+
stream. If the buffer_size is not given, it defaults to
|
|
326
|
+
DEFAULT_BUFFER_SIZE.
|
|
327
|
+
"""
|
|
127
328
|
def __enter__(self) -> Self: ...
|
|
128
329
|
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
|
|
129
330
|
def write(self, buffer: ReadableBuffer, /) -> int: ...
|
|
130
331
|
|
|
131
332
|
class BufferedRandom(BufferedReader, BufferedWriter): # type: ignore[misc] # incompatible definitions of methods in the base classes
|
|
333
|
+
"""
|
|
334
|
+
A buffered interface to random access streams.
|
|
335
|
+
|
|
336
|
+
The constructor creates a reader and writer for a seekable stream,
|
|
337
|
+
raw, given in the first argument. If the buffer_size is omitted it
|
|
338
|
+
defaults to DEFAULT_BUFFER_SIZE.
|
|
339
|
+
"""
|
|
132
340
|
def __enter__(self) -> Self: ...
|
|
133
341
|
def seek(self, target: int, whence: int = 0, /) -> int: ... # stubtest needs this
|
|
134
342
|
|
|
135
343
|
class BufferedRWPair(BufferedIOBase):
|
|
344
|
+
"""
|
|
345
|
+
A buffered reader and writer object together.
|
|
346
|
+
|
|
347
|
+
A buffered reader object and buffered writer object put together to
|
|
348
|
+
form a sequential IO object that can read and write. This is typically
|
|
349
|
+
used with a socket or two-way pipe.
|
|
350
|
+
|
|
351
|
+
reader and writer are RawIOBase objects that are readable and
|
|
352
|
+
writeable respectively. If the buffer_size is omitted it defaults to
|
|
353
|
+
DEFAULT_BUFFER_SIZE.
|
|
354
|
+
"""
|
|
136
355
|
def __init__(self, reader: RawIOBase, writer: RawIOBase, buffer_size: int = ...) -> None: ...
|
|
137
356
|
def peek(self, size: int = ..., /) -> bytes: ...
|
|
138
357
|
|
|
@@ -140,14 +359,59 @@ class TextIOBase(IOBase):
|
|
|
140
359
|
encoding: str
|
|
141
360
|
errors: str | None
|
|
142
361
|
newlines: str | tuple[str, ...] | None
|
|
143
|
-
def __iter__(self) -> Iterator[str]:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
def
|
|
150
|
-
|
|
362
|
+
def __iter__(self) -> Iterator[str]:
|
|
363
|
+
"""Implement iter(self)."""
|
|
364
|
+
...
|
|
365
|
+
def __next__(self) -> str:
|
|
366
|
+
"""Implement next(self)."""
|
|
367
|
+
...
|
|
368
|
+
def detach(self) -> BinaryIO:
|
|
369
|
+
"""
|
|
370
|
+
Separate the underlying buffer from the TextIOBase and return it.
|
|
371
|
+
|
|
372
|
+
After the underlying buffer has been detached, the TextIO is in an
|
|
373
|
+
unusable state.
|
|
374
|
+
"""
|
|
375
|
+
...
|
|
376
|
+
def write(self, s: str, /) -> int:
|
|
377
|
+
"""
|
|
378
|
+
Write string to stream.
|
|
379
|
+
Returns the number of characters written (which is always equal to
|
|
380
|
+
the length of the string).
|
|
381
|
+
"""
|
|
382
|
+
...
|
|
383
|
+
def writelines(self, lines: Iterable[str], /) -> None:
|
|
384
|
+
"""
|
|
385
|
+
Write a list of lines to stream.
|
|
386
|
+
|
|
387
|
+
Line separators are not added, so it is usual for each of the
|
|
388
|
+
lines provided to have a line separator at the end.
|
|
389
|
+
"""
|
|
390
|
+
...
|
|
391
|
+
def readline(self, size: int = ..., /) -> str:
|
|
392
|
+
"""
|
|
393
|
+
Read until newline or EOF.
|
|
394
|
+
|
|
395
|
+
Returns an empty string if EOF is hit immediately.
|
|
396
|
+
"""
|
|
397
|
+
...
|
|
398
|
+
def readlines(self, hint: int = -1, /) -> list[str]:
|
|
399
|
+
"""
|
|
400
|
+
Return a list of lines from the stream.
|
|
401
|
+
|
|
402
|
+
hint can be specified to control the number of lines read: no more
|
|
403
|
+
lines will be read if the total size (in bytes/characters) of all
|
|
404
|
+
lines so far exceeds hint.
|
|
405
|
+
"""
|
|
406
|
+
...
|
|
407
|
+
def read(self, size: int | None = ..., /) -> str:
|
|
408
|
+
"""
|
|
409
|
+
Read at most n characters from stream.
|
|
410
|
+
|
|
411
|
+
Read from underlying buffer until we have n characters or we hit EOF.
|
|
412
|
+
If n is negative or omitted, read until EOF.
|
|
413
|
+
"""
|
|
414
|
+
...
|
|
151
415
|
|
|
152
416
|
@type_check_only
|
|
153
417
|
class _WrappedBuffer(Protocol):
|
|
@@ -176,6 +440,36 @@ class _WrappedBuffer(Protocol):
|
|
|
176
440
|
# TODO: Should be generic over the buffer type, but needs to wait for
|
|
177
441
|
# TypeVar defaults.
|
|
178
442
|
class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible definitions of write in the base classes
|
|
443
|
+
r"""
|
|
444
|
+
Character and line based layer over a BufferedIOBase object, buffer.
|
|
445
|
+
|
|
446
|
+
encoding gives the name of the encoding that the stream will be
|
|
447
|
+
decoded or encoded with. It defaults to locale.getpreferredencoding(False).
|
|
448
|
+
|
|
449
|
+
errors determines the strictness of encoding and decoding (see
|
|
450
|
+
help(codecs.Codec) or the documentation for codecs.register) and
|
|
451
|
+
defaults to "strict".
|
|
452
|
+
|
|
453
|
+
newline controls how line endings are handled. It can be None, '',
|
|
454
|
+
'\n', '\r', and '\r\n'. It works as follows:
|
|
455
|
+
|
|
456
|
+
* On input, if newline is None, universal newlines mode is
|
|
457
|
+
enabled. Lines in the input can end in '\n', '\r', or '\r\n', and
|
|
458
|
+
these are translated into '\n' before being returned to the
|
|
459
|
+
caller. If it is '', universal newline mode is enabled, but line
|
|
460
|
+
endings are returned to the caller untranslated. If it has any of
|
|
461
|
+
the other legal values, input lines are only terminated by the given
|
|
462
|
+
string, and the line ending is returned to the caller untranslated.
|
|
463
|
+
|
|
464
|
+
* On output, if newline is None, any '\n' characters written are
|
|
465
|
+
translated to the system default line separator, os.linesep. If
|
|
466
|
+
newline is '' or '\n', no translation takes place. If newline is any
|
|
467
|
+
of the other legal values, any '\n' characters written are translated
|
|
468
|
+
to the given string.
|
|
469
|
+
|
|
470
|
+
If line_buffering is True, a call to flush is implied when a call to
|
|
471
|
+
write contains a newline character.
|
|
472
|
+
"""
|
|
179
473
|
def __init__(
|
|
180
474
|
self,
|
|
181
475
|
buffer: _WrappedBuffer,
|
|
@@ -202,29 +496,93 @@ class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible d
|
|
|
202
496
|
newline: str | None = None,
|
|
203
497
|
line_buffering: bool | None = None,
|
|
204
498
|
write_through: bool | None = None,
|
|
205
|
-
) -> None:
|
|
499
|
+
) -> None:
|
|
500
|
+
"""
|
|
501
|
+
Reconfigure the text stream with new parameters.
|
|
502
|
+
|
|
503
|
+
This also does an implicit stream flush.
|
|
504
|
+
"""
|
|
505
|
+
...
|
|
206
506
|
# These are inherited from TextIOBase, but must exist in the stub to satisfy mypy.
|
|
207
507
|
def __enter__(self) -> Self: ...
|
|
208
|
-
def __iter__(self) -> Iterator[str]:
|
|
209
|
-
|
|
210
|
-
|
|
508
|
+
def __iter__(self) -> Iterator[str]:
|
|
509
|
+
"""Implement iter(self)."""
|
|
510
|
+
...
|
|
511
|
+
def __next__(self) -> str:
|
|
512
|
+
"""Implement next(self)."""
|
|
513
|
+
...
|
|
514
|
+
def writelines(self, lines: Iterable[str], /) -> None:
|
|
515
|
+
"""
|
|
516
|
+
Write a list of lines to stream.
|
|
517
|
+
|
|
518
|
+
Line separators are not added, so it is usual for each of the
|
|
519
|
+
lines provided to have a line separator at the end.
|
|
520
|
+
"""
|
|
521
|
+
...
|
|
211
522
|
def readline(self, size: int = -1, /) -> str: ... # type: ignore[override]
|
|
212
|
-
def readlines(self, hint: int = -1, /) -> list[str]:
|
|
523
|
+
def readlines(self, hint: int = -1, /) -> list[str]:
|
|
524
|
+
"""
|
|
525
|
+
Return a list of lines from the stream.
|
|
526
|
+
|
|
527
|
+
hint can be specified to control the number of lines read: no more
|
|
528
|
+
lines will be read if the total size (in bytes/characters) of all
|
|
529
|
+
lines so far exceeds hint.
|
|
530
|
+
"""
|
|
531
|
+
...
|
|
213
532
|
# Equals the "buffer" argument passed in to the constructor.
|
|
214
533
|
def detach(self) -> BinaryIO: ...
|
|
215
534
|
# TextIOWrapper's version of seek only supports a limited subset of
|
|
216
535
|
# operations.
|
|
217
|
-
def seek(self, cookie: int, whence: int = 0, /) -> int:
|
|
536
|
+
def seek(self, cookie: int, whence: int = 0, /) -> int:
|
|
537
|
+
"""
|
|
538
|
+
Set the stream position, and return the new stream position.
|
|
539
|
+
|
|
540
|
+
cookie
|
|
541
|
+
Zero or an opaque number returned by tell().
|
|
542
|
+
whence
|
|
543
|
+
The relative position to seek from.
|
|
544
|
+
|
|
545
|
+
Four operations are supported, given by the following argument
|
|
546
|
+
combinations:
|
|
547
|
+
|
|
548
|
+
- seek(0, SEEK_SET): Rewind to the start of the stream.
|
|
549
|
+
- seek(cookie, SEEK_SET): Restore a previous position;
|
|
550
|
+
'cookie' must be a number returned by tell().
|
|
551
|
+
- seek(0, SEEK_END): Fast-forward to the end of the stream.
|
|
552
|
+
- seek(0, SEEK_CUR): Leave the current stream position unchanged.
|
|
553
|
+
|
|
554
|
+
Any other argument combinations are invalid,
|
|
555
|
+
and may raise exceptions.
|
|
556
|
+
"""
|
|
557
|
+
...
|
|
218
558
|
|
|
219
559
|
class StringIO(TextIOWrapper):
|
|
560
|
+
"""
|
|
561
|
+
Text I/O implementation using an in-memory buffer.
|
|
562
|
+
|
|
563
|
+
The initial_value argument sets the value of object. The newline
|
|
564
|
+
argument is like the one of TextIOWrapper's constructor.
|
|
565
|
+
"""
|
|
220
566
|
def __init__(self, initial_value: str | None = ..., newline: str | None = ...) -> None: ...
|
|
221
567
|
# StringIO does not contain a "name" field. This workaround is necessary
|
|
222
568
|
# to allow StringIO sub-classes to add this field, as it is defined
|
|
223
569
|
# as a read-only property on IO[].
|
|
224
570
|
name: Any
|
|
225
|
-
def getvalue(self) -> str:
|
|
571
|
+
def getvalue(self) -> str:
|
|
572
|
+
"""Retrieve the entire contents of the object."""
|
|
573
|
+
...
|
|
226
574
|
|
|
227
575
|
class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
|
|
576
|
+
r"""
|
|
577
|
+
Codec used when reading a file in universal newlines mode.
|
|
578
|
+
|
|
579
|
+
It wraps another incremental decoder, translating \r\n and \r into \n.
|
|
580
|
+
It also records the types of newlines encountered. When used with
|
|
581
|
+
translate=False, it ensures that the newline sequence is returned in
|
|
582
|
+
one piece. When used with decoder=None, it expects unicode strings as
|
|
583
|
+
decode input and translates newlines without first invoking an external
|
|
584
|
+
decoder.
|
|
585
|
+
"""
|
|
228
586
|
def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ...
|
|
229
587
|
def decode(self, input: ReadableBuffer | str, final: bool = False) -> str: ...
|
|
230
588
|
@property
|
|
@@ -233,6 +591,32 @@ class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
|
|
|
233
591
|
|
|
234
592
|
if sys.version_info >= (3, 10):
|
|
235
593
|
@overload
|
|
236
|
-
def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]:
|
|
594
|
+
def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]:
|
|
595
|
+
"""
|
|
596
|
+
A helper function to choose the text encoding.
|
|
597
|
+
|
|
598
|
+
When encoding is not None, just return it.
|
|
599
|
+
Otherwise, return the default text encoding (i.e. "locale").
|
|
600
|
+
|
|
601
|
+
This function emits an EncodingWarning if encoding is None and
|
|
602
|
+
sys.flags.warn_default_encoding is true.
|
|
603
|
+
|
|
604
|
+
This can be used in APIs with an encoding=None parameter.
|
|
605
|
+
However, please consider using encoding="utf-8" for new APIs.
|
|
606
|
+
"""
|
|
607
|
+
...
|
|
237
608
|
@overload
|
|
238
|
-
def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T:
|
|
609
|
+
def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T:
|
|
610
|
+
"""
|
|
611
|
+
A helper function to choose the text encoding.
|
|
612
|
+
|
|
613
|
+
When encoding is not None, just return it.
|
|
614
|
+
Otherwise, return the default text encoding (i.e. "locale").
|
|
615
|
+
|
|
616
|
+
This function emits an EncodingWarning if encoding is None and
|
|
617
|
+
sys.flags.warn_default_encoding is true.
|
|
618
|
+
|
|
619
|
+
This can be used in APIs with an encoding=None parameter.
|
|
620
|
+
However, please consider using encoding="utf-8" for new APIs.
|
|
621
|
+
"""
|
|
622
|
+
...
|