4 # 'bytes' paths are not properly supported: they don't work with all functions,
\r
5 # sometimes they only work partially (broken exception messages), and the test
\r
6 # cases don't use them.
\r
9 List, Iterable, Callable, Any, Tuple, Sequence, NamedTuple, IO,
\r
10 AnyStr, Optional, Union, Set, TypeVar, overload, Type, Protocol
\r
13 if sys.version_info >= (3, 6):
\r
14 _Path = Union[str, os.PathLike[str]]
\r
16 _AnyPath = TypeVar("_AnyPath", str, os.PathLike[str])
\r
17 # Return value of some functions that may either return a path-like object that was passed in or
\r
20 elif sys.version_info >= (3,):
\r
27 _AnyStr = TypeVar("_AnyStr", str, unicode)
\r
28 _AnyPath = TypeVar("_AnyPath", str, unicode)
\r
29 _PathReturn = Type[None]
\r
31 if sys.version_info >= (3,):
\r
32 class Error(OSError): ...
\r
33 class SameFileError(Error): ...
\r
34 class SpecialFileError(OSError): ...
\r
35 class ExecError(OSError): ...
\r
36 class ReadError(OSError): ...
\r
37 class RegistryError(Exception): ...
\r
39 class Error(EnvironmentError): ...
\r
40 class SpecialFileError(EnvironmentError): ...
\r
41 class ExecError(EnvironmentError): ...
\r
43 _S_co = TypeVar("_S_co", covariant=True)
\r
44 _S_contra = TypeVar("_S_contra", contravariant=True)
\r
46 class _Reader(Protocol[_S_co]):
\r
47 def read(self, length: int) -> _S_co: ...
\r
49 class _Writer(Protocol[_S_contra]):
\r
50 def write(self, data: _S_contra) -> Any: ...
\r
52 def copyfileobj(fsrc: _Reader[AnyStr], fdst: _Writer[AnyStr],
\r
53 length: int = ...) -> None: ...
\r
55 if sys.version_info >= (3,):
\r
56 def copyfile(src: _Path, dst: _AnyPath, *,
\r
57 follow_symlinks: bool = ...) -> _AnyPath: ...
\r
58 def copymode(src: _Path, dst: _Path, *,
\r
59 follow_symlinks: bool = ...) -> None: ...
\r
60 def copystat(src: _Path, dst: _Path, *,
\r
61 follow_symlinks: bool = ...) -> None: ...
\r
62 def copy(src: _Path, dst: _Path, *,
\r
63 follow_symlinks: bool = ...) -> _PathReturn: ...
\r
64 def copy2(src: _Path, dst: _Path, *,
\r
65 follow_symlinks: bool = ...) -> _PathReturn: ...
\r
67 def copyfile(src: _Path, dst: _Path) -> None: ...
\r
68 def copymode(src: _Path, dst: _Path) -> None: ...
\r
69 def copystat(src: _Path, dst: _Path) -> None: ...
\r
70 def copy(src: _Path, dst: _Path) -> _PathReturn: ...
\r
71 def copy2(src: _Path, dst: _Path) -> _PathReturn: ...
\r
73 def ignore_patterns(*patterns: _Path) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ...
\r
75 if sys.version_info >= (3,):
\r
76 _IgnoreFn = Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[_Path, List[str]], Iterable[str]]]
\r
77 def copytree(src: _Path, dst: _Path, symlinks: bool = ...,
\r
78 ignore: _IgnoreFn = ...,
\r
79 copy_function: Callable[[str, str], None] = ...,
\r
80 ignore_dangling_symlinks: bool = ...) -> _PathReturn: ...
\r
82 _IgnoreFn = Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]]
\r
83 def copytree(src: AnyStr, dst: AnyStr, symlinks: bool = ...,
\r
84 ignore: _IgnoreFn = ...) -> _PathReturn: ...
\r
86 if sys.version_info >= (3,):
\r
88 def rmtree(path: bytes, ignore_errors: bool = ...,
\r
89 onerror: Optional[Callable[[Any, str, Any], Any]] = ...) -> None: ...
\r
91 def rmtree(path: _AnyPath, ignore_errors: bool = ...,
\r
92 onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...) -> None: ...
\r
94 def rmtree(path: _AnyPath, ignore_errors: bool = ...,
\r
95 onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...) -> None: ...
\r
97 if sys.version_info >= (3, 5):
\r
98 _CopyFn = Union[Callable[[str, str], None], Callable[[_Path, _Path], None]]
\r
99 def move(src: _Path, dst: _Path,
\r
100 copy_function: _CopyFn = ...) -> _PathReturn: ...
\r
102 def move(src: _Path, dst: _Path) -> _PathReturn: ...
\r
104 if sys.version_info >= (3,):
\r
105 _ntuple_diskusage = NamedTuple('usage', [('total', int),
\r
108 def disk_usage(path: _Path) -> _ntuple_diskusage: ...
\r
109 def chown(path: _Path, user: Optional[str] = ...,
\r
110 group: Optional[str] = ...) -> None: ...
\r
111 def which(cmd: _Path, mode: int = ...,
\r
112 path: Optional[_Path] = ...) -> Optional[str]: ...
\r
114 def make_archive(base_name: _AnyStr, format: str, root_dir: Optional[_Path] = ...,
\r
115 base_dir: Optional[_Path] = ..., verbose: bool = ...,
\r
116 dry_run: bool = ..., owner: Optional[str] = ..., group: Optional[str] = ...,
\r
117 logger: Optional[Any] = ...) -> _AnyStr: ...
\r
118 def get_archive_formats() -> List[Tuple[str, str]]: ...
\r
120 def register_archive_format(name: str, function: Callable[..., Any],
\r
121 extra_args: Optional[Sequence[Union[Tuple[str, Any], List[Any]]]] = ...,
\r
122 description: str = ...) -> None: ...
\r
123 def unregister_archive_format(name: str) -> None: ...
\r
125 if sys.version_info >= (3,):
\r
126 # Should be _Path once http://bugs.python.org/issue30218 is fixed
\r
127 def unpack_archive(filename: str, extract_dir: Optional[_Path] = ...,
\r
128 format: Optional[str] = ...) -> None: ...
\r
129 def register_unpack_format(name: str, extensions: List[str], function: Any,
\r
130 extra_args: Sequence[Tuple[str, Any]] = ...,
\r
131 description: str = ...) -> None: ...
\r
132 def unregister_unpack_format(name: str) -> None: ...
\r
133 def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ...
\r
135 def get_terminal_size(fallback: Tuple[int, int] = ...) -> os.terminal_size: ...
\r