mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Start using selftype in 3.5 pathlib (#658)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
# Stubs for pathlib (Python 3.5)
|
||||
|
||||
from typing import Any, Generator, IO, Optional, Sequence, Tuple, Union
|
||||
from typing import Any, Generator, IO, Optional, Sequence, Tuple, Type, TypeVar, Union
|
||||
import os
|
||||
|
||||
_P = TypeVar('_P', 'PurePath')
|
||||
|
||||
class PurePath:
|
||||
parts = ... # type: Tuple[str, ...]
|
||||
drive = ... # type: str
|
||||
@@ -14,38 +16,38 @@ class PurePath:
|
||||
suffix = ... # type: str
|
||||
suffixes = ... # type: List[str]
|
||||
stem = ... # type: str
|
||||
def __new__(cls, *args: Union[str, PurePath]) -> PurePath: ...
|
||||
def __new__(cls: Type[_P], *args: Union[str, PurePath]) -> _P: ...
|
||||
def __lt__(self, other: PurePath) -> bool: ...
|
||||
def __le__(self, other: PurePath) -> bool: ...
|
||||
def __gt__(self, other: PurePath) -> bool: ...
|
||||
def __ge__(self, other: PurePath) -> bool: ...
|
||||
def __truediv__(self, key: Union[str, PurePath]) -> PurePath: ...
|
||||
def __rtruediv__(self, key: Union[str, PurePath]) -> PurePath: ...
|
||||
def __truediv__(self: _P, key: Union[str, PurePath]) -> _P: ...
|
||||
def __rtruediv__(self: _P, key: Union[str, PurePath]) -> _P: ...
|
||||
def __bytes__(self) -> bytes: ...
|
||||
def as_posix(self) -> str: ...
|
||||
def as_uri(self) -> str: ...
|
||||
def is_absolute(self) -> bool: ...
|
||||
def is_reserved(self) -> bool: ...
|
||||
def match(self, path_pattern: str) -> bool: ...
|
||||
def relative_to(self, *other: Union[str, PurePath]) -> PurePath: ...
|
||||
def with_name(self, name: str) -> PurePath: ...
|
||||
def with_suffix(self, suffix: str) -> PurePath: ...
|
||||
def joinpath(self, *other: Union[str, PurePath]) -> PurePath: ...
|
||||
def relative_to(self: _P, *other: Union[str, PurePath]) -> _P: ...
|
||||
def with_name(self: _P, name: str) -> _P: ...
|
||||
def with_suffix(self: _P, suffix: str) -> _P: ...
|
||||
def joinpath(self: _P, *other: Union[str, PurePath]) -> _P: ...
|
||||
|
||||
class PurePosixPath(PurePath): ...
|
||||
class PureWindowsPath(PurePath): ...
|
||||
|
||||
class Path(PurePath):
|
||||
@classmethod
|
||||
def cwd(cls) -> Path: ...
|
||||
def cwd(cls: Type[_P]) -> _P: ...
|
||||
@classmethod
|
||||
def home(cls) -> Path: ...
|
||||
def __new__(cls, *args: Union[str, PurePath], **kwargs: Any) -> Path: ...
|
||||
def absolute(self) -> Path: ...
|
||||
def home(cls: Type[_P]) -> _P: ...
|
||||
def __new__(cls: Type[_P], *args: Union[str, PurePath], **kwargs: Any) -> _P: ...
|
||||
def absolute(self: _P) -> _P: ...
|
||||
def stat(self) -> os.stat_result: ...
|
||||
def chmod(self, mode: int) -> None: ...
|
||||
def exists(self) -> bool: ...
|
||||
def expanduser(self) -> Path: ...
|
||||
def expanduser(self: _P) -> _P: ...
|
||||
def glob(self, pattern: str) -> Generator[Path, None, None]: ...
|
||||
def group(self) -> str: ...
|
||||
def is_dir(self) -> bool: ...
|
||||
@@ -69,7 +71,7 @@ class Path(PurePath):
|
||||
errors: Optional[str] = ...) -> str: ...
|
||||
def rename(self, target: Union[str, PurePath]) -> None: ...
|
||||
def replace(self, target: Union[str, PurePath]) -> None: ...
|
||||
def resolve(self) -> Path: ...
|
||||
def resolve(self: _P) -> _P: ...
|
||||
def rglob(self, pattern: str) -> Generator[Path, None, None]: ...
|
||||
def rmdir(self) -> None: ...
|
||||
def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ...
|
||||
@@ -81,16 +83,10 @@ class Path(PurePath):
|
||||
def write_text(self, data: str, encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...) -> int: ...
|
||||
|
||||
# The following methods are re-stubbed here even though they only actually exist in the base
|
||||
# class so that they return Path when called on a Path, rather than returning PurePath.
|
||||
# The following are repeated here even though they only actually exist in the base
|
||||
# class so that they return Path when used on a Path, rather than returning PurePath.
|
||||
parents = ... # type: Sequence[Path]
|
||||
parent = ... # type: Path
|
||||
def __truediv__(self, key: Union[str, PurePath]) -> Path: ...
|
||||
def __rtruediv__(self, key: Union[str, PurePath]) -> Path: ...
|
||||
def relative_to(self, *other: Union[str, PurePath]) -> Path: ...
|
||||
def with_name(self, name: str) -> Path: ...
|
||||
def with_suffix(self, suffix: str) -> Path: ...
|
||||
def joinpath(self, *args: Union[str, PurePath]) -> Path: ...
|
||||
|
||||
|
||||
class PosixPath(Path, PurePosixPath): ...
|
||||
|
||||
Reference in New Issue
Block a user