mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-20 19:01:15 +08:00
Use typing_extensions.Self in the stdlib (#9694)
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import bz2
|
||||
import io
|
||||
import sys
|
||||
from _typeshed import Self, StrOrBytesPath, StrPath
|
||||
from builtins import list as _list, type as Type # aliases to avoid name clashes with fields named "type" or "list"
|
||||
from _typeshed import StrOrBytesPath, StrPath
|
||||
from builtins import list as _list # aliases to avoid name clashes with fields named "type" or "list"
|
||||
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, ClassVar, Protocol, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, Self
|
||||
|
||||
__all__ = [
|
||||
"TarFile",
|
||||
@@ -141,14 +141,14 @@ class TarFile:
|
||||
errorlevel: int | None = None,
|
||||
copybufsize: int | None = None, # undocumented
|
||||
) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(
|
||||
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
|
||||
) -> None: ...
|
||||
def __iter__(self) -> Iterator[TarInfo]: ...
|
||||
@classmethod
|
||||
def open(
|
||||
cls: type[Self],
|
||||
cls,
|
||||
name: StrOrBytesPath | None = None,
|
||||
mode: str = "r",
|
||||
fileobj: IO[bytes] | None = None, # depends on mode
|
||||
@@ -166,7 +166,7 @@ class TarFile:
|
||||
) -> Self: ...
|
||||
@classmethod
|
||||
def taropen(
|
||||
cls: type[Self],
|
||||
cls,
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["r", "a", "w", "x"] = "r",
|
||||
fileobj: _Fileobj | None = None,
|
||||
@@ -184,7 +184,7 @@ class TarFile:
|
||||
@overload
|
||||
@classmethod
|
||||
def gzopen(
|
||||
cls: type[Self],
|
||||
cls,
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["r"] = "r",
|
||||
fileobj: _GzipReadableFileobj | None = None,
|
||||
@@ -202,7 +202,7 @@ class TarFile:
|
||||
@overload
|
||||
@classmethod
|
||||
def gzopen(
|
||||
cls: type[Self],
|
||||
cls,
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["w", "x"],
|
||||
fileobj: _GzipWritableFileobj | None = None,
|
||||
@@ -220,7 +220,7 @@ class TarFile:
|
||||
@overload
|
||||
@classmethod
|
||||
def bz2open(
|
||||
cls: type[Self],
|
||||
cls,
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["w", "x"],
|
||||
fileobj: _Bz2WritableFileobj | None = None,
|
||||
@@ -238,7 +238,7 @@ class TarFile:
|
||||
@overload
|
||||
@classmethod
|
||||
def bz2open(
|
||||
cls: type[Self],
|
||||
cls,
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["r"] = "r",
|
||||
fileobj: _Bz2ReadableFileobj | None = None,
|
||||
@@ -255,7 +255,7 @@ class TarFile:
|
||||
) -> Self: ...
|
||||
@classmethod
|
||||
def xzopen(
|
||||
cls: type[Self],
|
||||
cls,
|
||||
name: StrOrBytesPath | None,
|
||||
mode: Literal["r", "w", "x"] = "r",
|
||||
fileobj: IO[bytes] | None = None,
|
||||
@@ -346,9 +346,9 @@ class TarInfo:
|
||||
pax_headers: Mapping[str, str]
|
||||
def __init__(self, name: str = "") -> None: ...
|
||||
@classmethod
|
||||
def frombuf(cls: Type[Self], buf: bytes | bytearray, encoding: str, errors: str) -> Self: ...
|
||||
def frombuf(cls, buf: bytes | bytearray, encoding: str, errors: str) -> Self: ...
|
||||
@classmethod
|
||||
def fromtarfile(cls: Type[Self], tarfile: TarFile) -> Self: ...
|
||||
def fromtarfile(cls, tarfile: TarFile) -> Self: ...
|
||||
@property
|
||||
def linkpath(self) -> str: ...
|
||||
@linkpath.setter
|
||||
|
||||
Reference in New Issue
Block a user