| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent eab82c8 commit 8f5a835
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | + import io | ||
| 1 | 2 | import os | |
| 2 | 3 | import sys | |
| 3 | - from _typeshed import Self | ||
| 4 | + from _typeshed import Self, WriteableBuffer | ||
| 4 | 5 | from collections.abc import Iterable, Iterator | |
| 5 | 6 | from types import TracebackType | |
| 6 | 7 | from typing import IO, Any, AnyStr, Generic, overload | |
@@ -217,9 +218,14 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): | |||
| 217 | 218 | def write(self, s: AnyStr) -> int: ... | |
| 218 | 219 | def writelines(self, lines: Iterable[AnyStr]) -> None: ... | |
| 219 | 220 | ||
| 220 | - # It does not actually derive from IO[AnyStr], but it does implement the | ||
| 221 | - # protocol. | ||
| 222 | - class SpooledTemporaryFile(IO[AnyStr]): | ||
| 221 | + if sys.version_info >= (3, 11): | ||
| 222 | + _SpooledTemporaryFileBase = io.IOBase | ||
| 223 | + else: | ||
| 224 | + _SpooledTemporaryFileBase = object | ||
| 225 | + | ||
| 226 | + # It does not actually derive from IO[AnyStr], but it does mostly behave | ||
| 227 | + # like one. | ||
| 228 | + class SpooledTemporaryFile(IO[AnyStr], _SpooledTemporaryFileBase): | ||
| 223 | 229 | @property | |
| 224 | 230 | def encoding(self) -> str: ... # undocumented | |
| 225 | 231 | @property | |
@@ -318,20 +324,28 @@ class SpooledTemporaryFile(IO[AnyStr]): | |||
| 318 | 324 | def fileno(self) -> int: ... | |
| 319 | 325 | def flush(self) -> None: ... | |
| 320 | 326 | def isatty(self) -> bool: ... | |
| 321 | - def read(self, n: int = ...) -> AnyStr: ... | ||
| 322 | - def readline(self, limit: int = ...) -> AnyStr: ... | ||
| 323 | - def readlines(self, hint: int = ...) -> list[AnyStr]: ... | ||
| 327 | + if sys.version_info >= (3, 11): | ||
| 328 | + # These three work only if the SpooledTemporaryFile is opened in binary mode, | ||
| 329 | + # because the underlying object in text mode does not have these methods. | ||
| 330 | + def read1(self, __size: int = ...) -> AnyStr: ... | ||
| 331 | + def readinto(self, b: WriteableBuffer) -> int: ... | ||
| 332 | + def readinto1(self, b: WriteableBuffer) -> int: ... | ||
| 333 | + def detach(self) -> io.RawIOBase: ... | ||
| 334 | + | ||
| 335 | + def read(self, __n: int = ...) -> AnyStr: ... | ||
| 336 | + def readline(self, __limit: int | None = ...) -> AnyStr: ... # type: ignore[override] | ||
| 337 | + def readlines(self, __hint: int = ...) -> list[AnyStr]: ... # type: ignore[override] | ||
| 324 | 338 | def seek(self, offset: int, whence: int = ...) -> int: ... | |
| 325 | 339 | def tell(self) -> int: ... | |
| 326 | 340 | def truncate(self, size: int | None = ...) -> None: ... # type: ignore[override] | |
| 327 | 341 | def write(self, s: AnyStr) -> int: ... | |
| 328 | - def writelines(self, iterable: Iterable[AnyStr]) -> None: ... | ||
| 329 | - def __iter__(self) -> Iterator[AnyStr]: ... | ||
| 330 | - # Other than the following methods, which do not exist on SpooledTemporaryFile | ||
| 342 | + def writelines(self, iterable: Iterable[AnyStr]) -> None: ... # type: ignore[override] | ||
| 343 | + def __iter__(self) -> Iterator[AnyStr]: ... # type: ignore[override] | ||
| 344 | + # These exist at runtime only on 3.11+. | ||
| 331 | 345 | def readable(self) -> bool: ... | |
| 332 | 346 | def seekable(self) -> bool: ... | |
| 333 | 347 | def writable(self) -> bool: ... | |
| 334 | - def __next__(self) -> AnyStr: ... | ||
| 348 | + def __next__(self) -> AnyStr: ... # type: ignore[override] | ||
| 335 | 349 | if sys.version_info >= (3, 9): | |
| 336 | 350 | def __class_getitem__(cls, item: Any) -> GenericAlias: ... | |
| 337 | 351 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -149,10 +149,6 @@ subprocess.getstatusoutput | |||
| 149 | 149 | symtable.SymbolTable.has_exec | |
| 150 | 150 | sys.UnraisableHookArgs # Not exported from sys | |
| 151 | 151 | sys.exception | |
| 152 | - tempfile.SpooledTemporaryFile.detach | ||
| 153 | - tempfile.SpooledTemporaryFile.read1 | ||
| 154 | - tempfile.SpooledTemporaryFile.readinto | ||
| 155 | - tempfile.SpooledTemporaryFile.readinto1 | ||
| 156 | 152 | tkinter._VersionInfoType.__doc__ | |
| 157 | 153 | traceback.StackSummary.format_frame_summary | |
| 158 | 154 | traceback.TracebackException.__init__ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments