From 31d4a4277bf6acf419432b55ac35d39234137337 Mon Sep 17 00:00:00 2001 From: Matt Kimball Date: Mon, 6 Feb 2017 10:18:27 -0800 Subject: [PATCH] Added 'shutil' API changes between 3.3 and 3.5 (#915) As of Python 3.3, copymode, copystat, copy and copy2 take an optional argument, 'follow_symlinks'. As of Python 3.3, copytree and move return the destination. As of Python 3.5, move takes an optional copy function. As of Python 3.3, disk_usage, chown, which and get_terminal_size were added. --- stdlib/3/shutil.pyi | 65 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/stdlib/3/shutil.pyi b/stdlib/3/shutil.pyi index 1b917e6d1..c2865c831 100644 --- a/stdlib/3/shutil.pyi +++ b/stdlib/3/shutil.pyi @@ -7,25 +7,67 @@ import sys # sometimes they only work partially (broken exception messages), and the test # cases don't use them. -from typing import List, Iterable, Callable, Any, Tuple, Sequence, IO, AnyStr, Optional +from typing import ( + List, Iterable, Callable, Any, Tuple, Sequence, NamedTuple, IO, + AnyStr, Optional +) def copyfileobj(fsrc: IO[AnyStr], fdst: IO[AnyStr], length: int = ...) -> None: ... def copyfile(src: str, dst: str) -> None: ... -def copymode(src: str, dst: str) -> None: ... -def copystat(src: str, dst: str) -> None: ... -def copy(src: str, dst: str) -> None: ... -def copy2(src: str, dst: str) -> None: ... + +if sys.version_info >= (3, 3): + def copymode(src: str, dst: str, *, + follow_symlinks: bool = ...) -> None: ... + def copystat(src: str, dst: str, *, + follow_symlinks: bool = ...) -> None: ... + def copy(src: str, dst: str, *, + follow_symlinks: bool = ...) -> None: ... + def copy2(src: str, dst: str, *, + follow_symlinks: bool = ...) -> None: ... +else: + def copymode(src: str, dst: str) -> None: ... + def copystat(src: str, dst: str) -> None: ... + def copy(src: str, dst: str) -> None: ... + def copy2(src: str, dst: str) -> None: ... + def ignore_patterns(*patterns: str) -> Callable[[str, List[str]], Iterable[str]]: ... -def copytree(src: str, dst: str, symlinks: bool = ..., - ignore: Optional[Callable[[str, List[str]], Iterable[str]]] = ..., - copy_function: Callable[[str, str], None] = ..., - ignore_dangling_symlinks: bool = ...) -> None: ... + +if sys.version_info >= (3, 3): + def copytree(src: str, dst: str, symlinks: bool = ..., + ignore: Optional[Callable[[str, List[str]], + Iterable[str]]] = ..., + copy_function: Callable[[str, str], None] = ..., + ignore_dangling_symlinks: bool = ...) -> str: ... +else: + def copytree(src: str, dst: str, symlinks: bool = ..., + ignore: Optional[Callable[[str, List[str]], + Iterable[str]]] = ..., + copy_function: Callable[[str, str], None] = ..., + ignore_dangling_symlinks: bool = ...) -> None: ... + def rmtree(path: str, ignore_errors: bool = ..., onerror: Callable[[Any, str, Any], None] = ...) -> None: ... -def move(src: str, dst: str) -> None: ... + +if sys.version_info >= (3, 5): + def move(src: str, dst: str, + copy_function: Callable[[str, str], None] = ...) -> str: ... +elif sys.version_info >= (3, 3): + def move(src: str, dst: str) -> str: ... +else: + def move(src: str, dst: str) -> None: ... + +if sys.version_info >= (3, 3): + _ntuple_diskusage = NamedTuple('usage', [('total', int), + ('used', int), + ('free', int)]) + def disk_usage(path: str) -> _ntuple_diskusage: ... + def chown(path: str, user: Optional[str] = ..., + group: Optional[str] = ...) -> None: ... + def which(cmd: str, mode: int = ..., + path: Optional[str] = ...) -> Optional[str]: ... class Error(Exception): ... if sys.version_info >= (3, 4): @@ -48,4 +90,5 @@ def register_unpack_format(name: str, extensions: List[str], function: Any, def unregister_unpack_format(name: str) -> None: ... def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ... -def which(cmd: str, mode: int = ..., path: str = ...) -> Optional[str]: ... +if sys.version_info >= (3, 3): + def get_terminal_size(fallback: Tuple[int, int] = ...) -> Tuple[int, int]: ...