diff --git a/stdlib/3/pathlib.pyi b/stdlib/3/pathlib.pyi index beb973e85..279e8d57e 100644 --- a/stdlib/3/pathlib.pyi +++ b/stdlib/3/pathlib.pyi @@ -8,8 +8,10 @@ _P = TypeVar("_P", bound=PurePath) if sys.version_info >= (3, 6): _PurePathBase = os.PathLike[str] + _PathLike = os.PathLike[str] else: _PurePathBase = object + _PathLike = PurePath class PurePath(_PurePathBase): parts: Tuple[str, ...] @@ -20,23 +22,14 @@ class PurePath(_PurePathBase): suffix: str suffixes: List[str] stem: str - if sys.version_info < (3, 5): - def __init__(self, *pathsegments: str) -> None: ... - elif sys.version_info < (3, 6): - def __new__(cls: Type[_P], *args: Union[str, PurePath]) -> _P: ... - else: - def __new__(cls: Type[_P], *args: Union[str, os.PathLike[str]]) -> _P: ... + def __new__(cls: Type[_P], *args: Union[str, _PathLike]) -> _P: ... def __hash__(self) -> int: ... def __lt__(self, other: PurePath) -> bool: ... def __le__(self, other: PurePath) -> bool: ... def __gt__(self, other: PurePath) -> bool: ... def __ge__(self, other: PurePath) -> bool: ... - if sys.version_info < (3, 6): - def __truediv__(self: _P, key: Union[str, PurePath]) -> _P: ... - def __rtruediv__(self: _P, key: Union[str, PurePath]) -> _P: ... - else: - def __truediv__(self: _P, key: Union[str, os.PathLike[str]]) -> _P: ... - def __rtruediv__(self: _P, key: Union[str, os.PathLike[str]]) -> _P: ... + def __truediv__(self: _P, key: Union[str, _PathLike]) -> _P: ... + def __rtruediv__(self: _P, key: Union[str, _PathLike]) -> _P: ... if sys.version_info < (3,): def __div__(self: _P, key: Union[str, PurePath]) -> _P: ... def __bytes__(self) -> bytes: ... @@ -47,18 +40,12 @@ class PurePath(_PurePathBase): if sys.version_info >= (3, 9): def is_relative_to(self, *other: Union[str, os.PathLike[str]]) -> bool: ... def match(self, path_pattern: str) -> bool: ... - if sys.version_info < (3, 6): - def relative_to(self: _P, *other: Union[str, PurePath]) -> _P: ... - else: - def relative_to(self: _P, *other: Union[str, os.PathLike[str]]) -> _P: ... + def relative_to(self: _P, *other: Union[str, _PathLike]) -> _P: ... def with_name(self: _P, name: str) -> _P: ... if sys.version_info >= (3, 9): def with_stem(self: _P, stem: str) -> _P: ... def with_suffix(self: _P, suffix: str) -> _P: ... - if sys.version_info < (3, 6): - def joinpath(self: _P, *other: Union[str, PurePath]) -> _P: ... - else: - def joinpath(self: _P, *other: Union[str, os.PathLike[str]]) -> _P: ... + def joinpath(self: _P, *other: Union[str, _PathLike]) -> _P: ... @property def parents(self: _P) -> Sequence[_P]: ... @property @@ -68,6 +55,7 @@ class PurePosixPath(PurePath): ... class PureWindowsPath(PurePath): ... class Path(PurePath): + def __new__(cls: Type[_P], *args: Union[str, _PathLike], **kwargs: Any) -> _P: ... def __enter__(self) -> Path: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType] @@ -138,20 +126,15 @@ class Path(PurePath): def unlink(self, missing_ok: bool = ...) -> None: ... else: def unlink(self) -> None: ... - if sys.version_info >= (3, 5): - @classmethod - def home(cls: Type[_P]) -> _P: ... - if sys.version_info < (3, 6): - def __new__(cls: Type[_P], *args: Union[str, PurePath], **kwargs: Any) -> _P: ... - else: - def __new__(cls: Type[_P], *args: Union[str, os.PathLike[str]], **kwargs: Any) -> _P: ... - def absolute(self: _P) -> _P: ... - def expanduser(self: _P) -> _P: ... - def read_bytes(self) -> bytes: ... - def read_text(self, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ... - def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ... - def write_bytes(self, data: bytes) -> int: ... - def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ... + @classmethod + def home(cls: Type[_P]) -> _P: ... + def absolute(self: _P) -> _P: ... + def expanduser(self: _P) -> _P: ... + def read_bytes(self) -> bytes: ... + def read_text(self, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ... + def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ... + def write_bytes(self, data: bytes) -> int: ... + def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ... if sys.version_info >= (3, 8): def link_to(self, target: Union[str, bytes, os.PathLike[str]]) -> None: ... diff --git a/third_party/2/pathlib2.pyi b/third_party/2/pathlib2.pyi index beb973e85..279e8d57e 100644 --- a/third_party/2/pathlib2.pyi +++ b/third_party/2/pathlib2.pyi @@ -8,8 +8,10 @@ _P = TypeVar("_P", bound=PurePath) if sys.version_info >= (3, 6): _PurePathBase = os.PathLike[str] + _PathLike = os.PathLike[str] else: _PurePathBase = object + _PathLike = PurePath class PurePath(_PurePathBase): parts: Tuple[str, ...] @@ -20,23 +22,14 @@ class PurePath(_PurePathBase): suffix: str suffixes: List[str] stem: str - if sys.version_info < (3, 5): - def __init__(self, *pathsegments: str) -> None: ... - elif sys.version_info < (3, 6): - def __new__(cls: Type[_P], *args: Union[str, PurePath]) -> _P: ... - else: - def __new__(cls: Type[_P], *args: Union[str, os.PathLike[str]]) -> _P: ... + def __new__(cls: Type[_P], *args: Union[str, _PathLike]) -> _P: ... def __hash__(self) -> int: ... def __lt__(self, other: PurePath) -> bool: ... def __le__(self, other: PurePath) -> bool: ... def __gt__(self, other: PurePath) -> bool: ... def __ge__(self, other: PurePath) -> bool: ... - if sys.version_info < (3, 6): - def __truediv__(self: _P, key: Union[str, PurePath]) -> _P: ... - def __rtruediv__(self: _P, key: Union[str, PurePath]) -> _P: ... - else: - def __truediv__(self: _P, key: Union[str, os.PathLike[str]]) -> _P: ... - def __rtruediv__(self: _P, key: Union[str, os.PathLike[str]]) -> _P: ... + def __truediv__(self: _P, key: Union[str, _PathLike]) -> _P: ... + def __rtruediv__(self: _P, key: Union[str, _PathLike]) -> _P: ... if sys.version_info < (3,): def __div__(self: _P, key: Union[str, PurePath]) -> _P: ... def __bytes__(self) -> bytes: ... @@ -47,18 +40,12 @@ class PurePath(_PurePathBase): if sys.version_info >= (3, 9): def is_relative_to(self, *other: Union[str, os.PathLike[str]]) -> bool: ... def match(self, path_pattern: str) -> bool: ... - if sys.version_info < (3, 6): - def relative_to(self: _P, *other: Union[str, PurePath]) -> _P: ... - else: - def relative_to(self: _P, *other: Union[str, os.PathLike[str]]) -> _P: ... + def relative_to(self: _P, *other: Union[str, _PathLike]) -> _P: ... def with_name(self: _P, name: str) -> _P: ... if sys.version_info >= (3, 9): def with_stem(self: _P, stem: str) -> _P: ... def with_suffix(self: _P, suffix: str) -> _P: ... - if sys.version_info < (3, 6): - def joinpath(self: _P, *other: Union[str, PurePath]) -> _P: ... - else: - def joinpath(self: _P, *other: Union[str, os.PathLike[str]]) -> _P: ... + def joinpath(self: _P, *other: Union[str, _PathLike]) -> _P: ... @property def parents(self: _P) -> Sequence[_P]: ... @property @@ -68,6 +55,7 @@ class PurePosixPath(PurePath): ... class PureWindowsPath(PurePath): ... class Path(PurePath): + def __new__(cls: Type[_P], *args: Union[str, _PathLike], **kwargs: Any) -> _P: ... def __enter__(self) -> Path: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType] @@ -138,20 +126,15 @@ class Path(PurePath): def unlink(self, missing_ok: bool = ...) -> None: ... else: def unlink(self) -> None: ... - if sys.version_info >= (3, 5): - @classmethod - def home(cls: Type[_P]) -> _P: ... - if sys.version_info < (3, 6): - def __new__(cls: Type[_P], *args: Union[str, PurePath], **kwargs: Any) -> _P: ... - else: - def __new__(cls: Type[_P], *args: Union[str, os.PathLike[str]], **kwargs: Any) -> _P: ... - def absolute(self: _P) -> _P: ... - def expanduser(self: _P) -> _P: ... - def read_bytes(self) -> bytes: ... - def read_text(self, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ... - def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ... - def write_bytes(self, data: bytes) -> int: ... - def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ... + @classmethod + def home(cls: Type[_P]) -> _P: ... + def absolute(self: _P) -> _P: ... + def expanduser(self: _P) -> _P: ... + def read_bytes(self) -> bytes: ... + def read_text(self, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ... + def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ... + def write_bytes(self, data: bytes) -> int: ... + def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ... if sys.version_info >= (3, 8): def link_to(self, target: Union[str, bytes, os.PathLike[str]]) -> None: ...