Add missing tarfile.open overload for writable objects (#12117)

This commit is contained in:
Max Muoto
2024-06-21 04:20:10 -05:00
committed by GitHub
parent 9817430896
commit 72a85f4c99

View File

@@ -103,10 +103,32 @@ PAX_NAME_FIELDS: set[str]
ENCODING: str
_FileCreationModes: TypeAlias = Literal["a", "w", "x"]
@overload
def open(
name: StrOrBytesPath | None = None,
mode: str = "r",
fileobj: IO[bytes] | None = None, # depends on mode
fileobj: IO[bytes] | None = None,
bufsize: int = 10240,
*,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
errors: str = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
compresslevel: int | None = ...,
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
) -> TarFile: ...
@overload
def open(
name: StrOrBytesPath | None = None,
mode: _FileCreationModes = ...,
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
*,
format: int | None = ...,