mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-25 12:26:44 +08:00
Big diff: Use new "|" union syntax (#5872)
This commit is contained in:
@@ -5,7 +5,7 @@ from _typeshed import Self, StrOrBytesPath, StrPath
|
||||
from collections.abc import Callable, Iterable, Iterator, Mapping
|
||||
from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj
|
||||
from types import TracebackType
|
||||
from typing import IO, Dict, List, Optional, Protocol, Set, Tuple, Type, TypeVar, Union, overload
|
||||
from typing import IO, Dict, List, Protocol, Set, Tuple, Type, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
_TF = TypeVar("_TF", bound=TarFile)
|
||||
@@ -72,21 +72,21 @@ PAX_NAME_FIELDS: Set[str]
|
||||
ENCODING: str
|
||||
|
||||
def open(
|
||||
name: Optional[StrOrBytesPath] = ...,
|
||||
name: StrOrBytesPath | None = ...,
|
||||
mode: str = ...,
|
||||
fileobj: Optional[IO[bytes]] = ..., # depends on mode
|
||||
fileobj: IO[bytes] | None = ..., # depends on mode
|
||||
bufsize: int = ...,
|
||||
*,
|
||||
format: Optional[int] = ...,
|
||||
tarinfo: Optional[Type[TarInfo]] = ...,
|
||||
dereference: Optional[bool] = ...,
|
||||
ignore_zeros: Optional[bool] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
format: int | None = ...,
|
||||
tarinfo: Type[TarInfo] | None = ...,
|
||||
dereference: bool | None = ...,
|
||||
ignore_zeros: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str = ...,
|
||||
pax_headers: Optional[Mapping[str, str]] = ...,
|
||||
debug: Optional[int] = ...,
|
||||
errorlevel: Optional[int] = ...,
|
||||
compresslevel: Optional[int] = ...,
|
||||
pax_headers: Mapping[str, str] | None = ...,
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
compresslevel: int | None = ...,
|
||||
) -> TarFile: ...
|
||||
|
||||
class ExFileObject(io.BufferedReader):
|
||||
@@ -94,180 +94,180 @@ class ExFileObject(io.BufferedReader):
|
||||
|
||||
class TarFile:
|
||||
OPEN_METH: Mapping[str, str]
|
||||
name: Optional[StrOrBytesPath]
|
||||
name: StrOrBytesPath | None
|
||||
mode: Literal["r", "a", "w", "x"]
|
||||
fileobj: Optional[_Fileobj]
|
||||
format: Optional[int]
|
||||
fileobj: _Fileobj | None
|
||||
format: int | None
|
||||
tarinfo: Type[TarInfo]
|
||||
dereference: Optional[bool]
|
||||
ignore_zeros: Optional[bool]
|
||||
encoding: Optional[str]
|
||||
dereference: bool | None
|
||||
ignore_zeros: bool | None
|
||||
encoding: str | None
|
||||
errors: str
|
||||
fileobject: Type[ExFileObject]
|
||||
pax_headers: Optional[Mapping[str, str]]
|
||||
debug: Optional[int]
|
||||
errorlevel: Optional[int]
|
||||
pax_headers: Mapping[str, str] | None
|
||||
debug: int | None
|
||||
errorlevel: int | None
|
||||
offset: int # undocumented
|
||||
def __init__(
|
||||
self,
|
||||
name: Optional[StrOrBytesPath] = ...,
|
||||
name: StrOrBytesPath | None = ...,
|
||||
mode: Literal["r", "a", "w", "x"] = ...,
|
||||
fileobj: Optional[_Fileobj] = ...,
|
||||
format: Optional[int] = ...,
|
||||
tarinfo: Optional[Type[TarInfo]] = ...,
|
||||
dereference: Optional[bool] = ...,
|
||||
ignore_zeros: Optional[bool] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
fileobj: _Fileobj | None = ...,
|
||||
format: int | None = ...,
|
||||
tarinfo: Type[TarInfo] | None = ...,
|
||||
dereference: bool | None = ...,
|
||||
ignore_zeros: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str = ...,
|
||||
pax_headers: Optional[Mapping[str, str]] = ...,
|
||||
debug: Optional[int] = ...,
|
||||
errorlevel: Optional[int] = ...,
|
||||
copybufsize: Optional[int] = ..., # undocumented
|
||||
pax_headers: Mapping[str, str] | None = ...,
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
copybufsize: int | None = ..., # undocumented
|
||||
) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
def __iter__(self) -> Iterator[TarInfo]: ...
|
||||
@classmethod
|
||||
def open(
|
||||
cls: Type[_TF],
|
||||
name: Optional[StrOrBytesPath] = ...,
|
||||
name: StrOrBytesPath | None = ...,
|
||||
mode: str = ...,
|
||||
fileobj: Optional[IO[bytes]] = ..., # depends on mode
|
||||
fileobj: IO[bytes] | None = ..., # depends on mode
|
||||
bufsize: int = ...,
|
||||
*,
|
||||
format: Optional[int] = ...,
|
||||
tarinfo: Optional[Type[TarInfo]] = ...,
|
||||
dereference: Optional[bool] = ...,
|
||||
ignore_zeros: Optional[bool] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
format: int | None = ...,
|
||||
tarinfo: Type[TarInfo] | None = ...,
|
||||
dereference: bool | None = ...,
|
||||
ignore_zeros: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str = ...,
|
||||
pax_headers: Optional[Mapping[str, str]] = ...,
|
||||
debug: Optional[int] = ...,
|
||||
errorlevel: Optional[int] = ...,
|
||||
pax_headers: Mapping[str, str] | None = ...,
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
) -> _TF: ...
|
||||
@classmethod
|
||||
def taropen(
|
||||
cls: Type[_TF],
|
||||
name: Optional[StrOrBytesPath],
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["r", "a", "w", "x"] = ...,
|
||||
fileobj: Optional[_Fileobj] = ...,
|
||||
fileobj: _Fileobj | None = ...,
|
||||
*,
|
||||
compresslevel: int = ...,
|
||||
format: Optional[int] = ...,
|
||||
tarinfo: Optional[Type[TarInfo]] = ...,
|
||||
dereference: Optional[bool] = ...,
|
||||
ignore_zeros: Optional[bool] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
pax_headers: Optional[Mapping[str, str]] = ...,
|
||||
debug: Optional[int] = ...,
|
||||
errorlevel: Optional[int] = ...,
|
||||
format: int | None = ...,
|
||||
tarinfo: Type[TarInfo] | None = ...,
|
||||
dereference: bool | None = ...,
|
||||
ignore_zeros: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
pax_headers: Mapping[str, str] | None = ...,
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
) -> _TF: ...
|
||||
@overload
|
||||
@classmethod
|
||||
def gzopen(
|
||||
cls: Type[_TF],
|
||||
name: Optional[StrOrBytesPath],
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["r"] = ...,
|
||||
fileobj: Optional[_GzipReadableFileobj] = ...,
|
||||
fileobj: _GzipReadableFileobj | None = ...,
|
||||
compresslevel: int = ...,
|
||||
*,
|
||||
format: Optional[int] = ...,
|
||||
tarinfo: Optional[Type[TarInfo]] = ...,
|
||||
dereference: Optional[bool] = ...,
|
||||
ignore_zeros: Optional[bool] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
pax_headers: Optional[Mapping[str, str]] = ...,
|
||||
debug: Optional[int] = ...,
|
||||
errorlevel: Optional[int] = ...,
|
||||
format: int | None = ...,
|
||||
tarinfo: Type[TarInfo] | None = ...,
|
||||
dereference: bool | None = ...,
|
||||
ignore_zeros: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
pax_headers: Mapping[str, str] | None = ...,
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
) -> _TF: ...
|
||||
@overload
|
||||
@classmethod
|
||||
def gzopen(
|
||||
cls: Type[_TF],
|
||||
name: Optional[StrOrBytesPath],
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["w", "x"],
|
||||
fileobj: Optional[_GzipWritableFileobj] = ...,
|
||||
fileobj: _GzipWritableFileobj | None = ...,
|
||||
compresslevel: int = ...,
|
||||
*,
|
||||
format: Optional[int] = ...,
|
||||
tarinfo: Optional[Type[TarInfo]] = ...,
|
||||
dereference: Optional[bool] = ...,
|
||||
ignore_zeros: Optional[bool] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
pax_headers: Optional[Mapping[str, str]] = ...,
|
||||
debug: Optional[int] = ...,
|
||||
errorlevel: Optional[int] = ...,
|
||||
format: int | None = ...,
|
||||
tarinfo: Type[TarInfo] | None = ...,
|
||||
dereference: bool | None = ...,
|
||||
ignore_zeros: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
pax_headers: Mapping[str, str] | None = ...,
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
) -> _TF: ...
|
||||
@overload
|
||||
@classmethod
|
||||
def bz2open(
|
||||
cls: Type[_TF],
|
||||
name: Optional[StrOrBytesPath],
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["w", "x"],
|
||||
fileobj: Optional[_Bz2WritableFileobj] = ...,
|
||||
fileobj: _Bz2WritableFileobj | None = ...,
|
||||
compresslevel: int = ...,
|
||||
*,
|
||||
format: Optional[int] = ...,
|
||||
tarinfo: Optional[Type[TarInfo]] = ...,
|
||||
dereference: Optional[bool] = ...,
|
||||
ignore_zeros: Optional[bool] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
pax_headers: Optional[Mapping[str, str]] = ...,
|
||||
debug: Optional[int] = ...,
|
||||
errorlevel: Optional[int] = ...,
|
||||
format: int | None = ...,
|
||||
tarinfo: Type[TarInfo] | None = ...,
|
||||
dereference: bool | None = ...,
|
||||
ignore_zeros: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
pax_headers: Mapping[str, str] | None = ...,
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
) -> _TF: ...
|
||||
@overload
|
||||
@classmethod
|
||||
def bz2open(
|
||||
cls: Type[_TF],
|
||||
name: Optional[StrOrBytesPath],
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["r"] = ...,
|
||||
fileobj: Optional[_Bz2ReadableFileobj] = ...,
|
||||
fileobj: _Bz2ReadableFileobj | None = ...,
|
||||
compresslevel: int = ...,
|
||||
*,
|
||||
format: Optional[int] = ...,
|
||||
tarinfo: Optional[Type[TarInfo]] = ...,
|
||||
dereference: Optional[bool] = ...,
|
||||
ignore_zeros: Optional[bool] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
pax_headers: Optional[Mapping[str, str]] = ...,
|
||||
debug: Optional[int] = ...,
|
||||
errorlevel: Optional[int] = ...,
|
||||
format: int | None = ...,
|
||||
tarinfo: Type[TarInfo] | None = ...,
|
||||
dereference: bool | None = ...,
|
||||
ignore_zeros: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
pax_headers: Mapping[str, str] | None = ...,
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
) -> _TF: ...
|
||||
@classmethod
|
||||
def xzopen(
|
||||
cls: Type[_TF],
|
||||
name: Optional[StrOrBytesPath],
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["r", "w", "x"] = ...,
|
||||
fileobj: Optional[IO[bytes]] = ...,
|
||||
preset: Optional[int] = ...,
|
||||
fileobj: IO[bytes] | None = ...,
|
||||
preset: int | None = ...,
|
||||
*,
|
||||
format: Optional[int] = ...,
|
||||
tarinfo: Optional[Type[TarInfo]] = ...,
|
||||
dereference: Optional[bool] = ...,
|
||||
ignore_zeros: Optional[bool] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
pax_headers: Optional[Mapping[str, str]] = ...,
|
||||
debug: Optional[int] = ...,
|
||||
errorlevel: Optional[int] = ...,
|
||||
format: int | None = ...,
|
||||
tarinfo: Type[TarInfo] | None = ...,
|
||||
dereference: bool | None = ...,
|
||||
ignore_zeros: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
pax_headers: Mapping[str, str] | None = ...,
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
) -> _TF: ...
|
||||
def getmember(self, name: str) -> TarInfo: ...
|
||||
def getmembers(self) -> List[TarInfo]: ...
|
||||
def getnames(self) -> List[str]: ...
|
||||
def list(self, verbose: bool = ..., *, members: Optional[List[TarInfo]] = ...) -> None: ...
|
||||
def next(self) -> Optional[TarInfo]: ...
|
||||
def list(self, verbose: bool = ..., *, members: List[TarInfo] | None = ...) -> None: ...
|
||||
def next(self) -> TarInfo | None: ...
|
||||
def extractall(
|
||||
self, path: StrOrBytesPath = ..., members: Optional[Iterable[TarInfo]] = ..., *, numeric_owner: bool = ...
|
||||
self, path: StrOrBytesPath = ..., members: Iterable[TarInfo] | None = ..., *, numeric_owner: bool = ...
|
||||
) -> None: ...
|
||||
def extract(
|
||||
self, member: Union[str, TarInfo], path: StrOrBytesPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ...
|
||||
self, member: str | TarInfo, path: StrOrBytesPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ...
|
||||
) -> None: ...
|
||||
def _extract_member(
|
||||
self, tarinfo: TarInfo, targetpath: str, set_attrs: bool = ..., numeric_owner: bool = ...
|
||||
) -> None: ... # undocumented
|
||||
def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ...
|
||||
def extractfile(self, member: str | TarInfo) -> IO[bytes] | None: ...
|
||||
def makedir(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented
|
||||
def makefile(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented
|
||||
def makeunknown(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented
|
||||
@@ -281,29 +281,27 @@ class TarFile:
|
||||
def add(
|
||||
self,
|
||||
name: StrPath,
|
||||
arcname: Optional[StrPath] = ...,
|
||||
arcname: StrPath | None = ...,
|
||||
recursive: bool = ...,
|
||||
*,
|
||||
filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ...,
|
||||
filter: Callable[[TarInfo], TarInfo | None] | None = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def add(
|
||||
self,
|
||||
name: StrPath,
|
||||
arcname: Optional[StrPath] = ...,
|
||||
arcname: StrPath | None = ...,
|
||||
recursive: bool = ...,
|
||||
exclude: Optional[Callable[[str], bool]] = ...,
|
||||
exclude: Callable[[str], bool] | None = ...,
|
||||
*,
|
||||
filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ...,
|
||||
filter: Callable[[TarInfo], TarInfo | None] | None = ...,
|
||||
) -> None: ...
|
||||
def addfile(self, tarinfo: TarInfo, fileobj: Optional[IO[bytes]] = ...) -> None: ...
|
||||
def gettarinfo(
|
||||
self, name: Optional[str] = ..., arcname: Optional[str] = ..., fileobj: Optional[IO[bytes]] = ...
|
||||
) -> TarInfo: ...
|
||||
def addfile(self, tarinfo: TarInfo, fileobj: IO[bytes] | None = ...) -> None: ...
|
||||
def gettarinfo(self, name: str | None = ..., arcname: str | None = ..., fileobj: IO[bytes] | None = ...) -> TarInfo: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def is_tarfile(name: Union[StrOrBytesPath, IO[bytes]]) -> bool: ...
|
||||
def is_tarfile(name: StrOrBytesPath | IO[bytes]) -> bool: ...
|
||||
|
||||
else:
|
||||
def is_tarfile(name: StrOrBytesPath) -> bool: ...
|
||||
@@ -328,8 +326,8 @@ class TarInfo:
|
||||
devminor: int
|
||||
offset: int
|
||||
offset_data: int
|
||||
sparse: Optional[bytes]
|
||||
tarfile: Optional[TarFile]
|
||||
sparse: bytes | None
|
||||
tarfile: TarFile | None
|
||||
mode: int
|
||||
type: bytes
|
||||
linkname: str
|
||||
@@ -347,15 +345,15 @@ class TarInfo:
|
||||
def linkpath(self) -> str: ...
|
||||
@linkpath.setter
|
||||
def linkpath(self, linkname: str) -> None: ...
|
||||
def get_info(self) -> Mapping[str, Union[str, int, bytes, Mapping[str, str]]]: ...
|
||||
def tobuf(self, format: Optional[int] = ..., encoding: Optional[str] = ..., errors: str = ...) -> bytes: ...
|
||||
def get_info(self) -> Mapping[str, str | int | bytes | Mapping[str, str]]: ...
|
||||
def tobuf(self, format: int | None = ..., encoding: str | None = ..., errors: str = ...) -> bytes: ...
|
||||
def create_ustar_header(
|
||||
self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str
|
||||
self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str
|
||||
) -> bytes: ...
|
||||
def create_gnu_header(
|
||||
self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str
|
||||
self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str
|
||||
) -> bytes: ...
|
||||
def create_pax_header(self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str) -> bytes: ...
|
||||
def create_pax_header(self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str) -> bytes: ...
|
||||
@classmethod
|
||||
def create_pax_global_header(cls, pax_headers: Mapping[str, str]) -> bytes: ...
|
||||
def isfile(self) -> bool: ...
|
||||
|
||||
Reference in New Issue
Block a user