Skip to content

Commit 72a85f4

Browse files
authored
Add missing tarfile.open overload for writable objects (#12117)
1 parent 9817430 commit 72a85f4

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

stdlib/tarfile.pyi

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,32 @@ PAX_NAME_FIELDS: set[str]
103103

104104
ENCODING: str
105105

106+
_FileCreationModes: TypeAlias = Literal["a", "w", "x"]
107+
108+
@overload
106109
def open(
107110
name: StrOrBytesPath | None = None,
108111
mode: str = "r",
109-
fileobj: IO[bytes] | None = None, # depends on mode
112+
fileobj: IO[bytes] | None = None,
113+
bufsize: int = 10240,
114+
*,
115+
format: int | None = ...,
116+
tarinfo: type[TarInfo] | None = ...,
117+
dereference: bool | None = ...,
118+
ignore_zeros: bool | None = ...,
119+
encoding: str | None = ...,
120+
errors: str = ...,
121+
pax_headers: Mapping[str, str] | None = ...,
122+
debug: int | None = ...,
123+
errorlevel: int | None = ...,
124+
compresslevel: int | None = ...,
125+
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
126+
) -> TarFile: ...
127+
@overload
128+
def open(
129+
name: StrOrBytesPath | None = None,
130+
mode: _FileCreationModes = ...,
131+
fileobj: _Fileobj | None = None,
110132
bufsize: int = 10240,
111133
*,
112134
format: int | None = ...,

0 commit comments

Comments
 (0)