3 from _typeshed import StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
4 from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, TypeVar, Union, overload
6 _PathT = TypeVar("_PathT", str, os.PathLike[str])
7 # Return value of some functions that may either return a path-like object that was passed in or
11 class Error(OSError): ...
12 class SameFileError(Error): ...
13 class SpecialFileError(OSError): ...
14 class ExecError(OSError): ...
15 class ReadError(OSError): ...
16 class RegistryError(Exception): ...
18 def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ...
19 def copyfile(src: StrPath, dst: _PathT, *, follow_symlinks: bool = ...) -> _PathT: ...
20 def copymode(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ...
21 def copystat(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ...
22 def copy(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
23 def copy2(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
24 def ignore_patterns(*patterns: StrPath) -> Callable[[Any, list[str]], set[str]]: ...
26 if sys.version_info >= (3, 8):
31 ignore: None | Callable[[str, list[str]], Iterable[str]] | Callable[[StrPath, list[str]], Iterable[str]] = ...,
32 copy_function: Callable[[str, str], None] = ...,
33 ignore_dangling_symlinks: bool = ...,
34 dirs_exist_ok: bool = ...,
42 ignore: None | Callable[[str, list[str]], Iterable[str]] | Callable[[StrPath, list[str]], Iterable[str]] = ...,
43 copy_function: Callable[[str, str], None] = ...,
44 ignore_dangling_symlinks: bool = ...,
47 def rmtree(path: bytes | StrPath, ignore_errors: bool = ..., onerror: Callable[[Any, Any, Any], Any] | None = ...) -> None: ...
49 _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]]
51 if sys.version_info >= (3, 9):
52 def move(src: StrPath, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ...
55 # See https://bugs.python.org/issue32689
56 def move(src: str, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ...
58 class _ntuple_diskusage(NamedTuple):
63 def disk_usage(path: int | StrOrBytesPath) -> _ntuple_diskusage: ...
64 def chown(path: StrPath, user: str | int | None = ..., group: str | int | None = ...) -> None: ...
66 if sys.version_info >= (3, 8):
68 def which(cmd: StrPath, mode: int = ..., path: StrPath | None = ...) -> str | None: ...
70 def which(cmd: bytes, mode: int = ..., path: StrPath | None = ...) -> bytes | None: ...
73 def which(cmd: StrPath, mode: int = ..., path: StrPath | None = ...) -> str | None: ...
78 root_dir: StrPath | None = ...,
79 base_dir: StrPath | None = ...,
82 owner: str | None = ...,
83 group: str | None = ...,
84 logger: Any | None = ...,
86 def get_archive_formats() -> list[tuple[str, str]]: ...
87 def register_archive_format(
89 function: Callable[..., Any],
90 extra_args: Sequence[tuple[str, Any] | list[Any]] | None = ...,
91 description: str = ...,
93 def unregister_archive_format(name: str) -> None: ...
95 if sys.version_info >= (3, 7):
96 def unpack_archive(filename: StrPath, extract_dir: StrPath | None = ..., format: str | None = ...) -> None: ...
99 # See http://bugs.python.org/issue30218
100 def unpack_archive(filename: str, extract_dir: StrPath | None = ..., format: str | None = ...) -> None: ...
102 def register_unpack_format(
103 name: str, extensions: list[str], function: Any, extra_args: Sequence[tuple[str, Any]] | None = ..., description: str = ...
105 def unregister_unpack_format(name: str) -> None: ...
106 def get_unpack_formats() -> list[tuple[str, list[str], str]]: ...
107 def get_terminal_size(fallback: tuple[int, int] = ...) -> os.terminal_size: ...