From 482f207b3ceda9d862d73316213b0665c027551c Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 6 Apr 2018 11:22:15 -0700 Subject: [PATCH] os.fwalk supports bytes (#2013) python/cpython@8f6b344 and https://bugs.python.org/issue28682. I could not use the _PathLike alias because that includes bytes. Part of #1965. --- stdlib/3/os/__init__.pyi | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index e99d4f05d..9b56a8633 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -512,9 +512,23 @@ else: followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... if sys.version_info >= (3, 3): - def fwalk(top: _PathType = ..., topdown: bool = ..., - onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., - dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only + if sys.version_info >= (3, 7): + @overload + def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ..., + onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., + dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only + @overload + def fwalk(top: bytes, topdown: bool = ..., + onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., + dir_fd: Optional[int] = ...) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ... # Unix only + elif sys.version_info >= (3, 6): + def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ..., + onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., + dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only + else: + def fwalk(top: str = ..., topdown: bool = ..., + onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., + dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only def getxattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> bytes: ... # Linux only def listxattr(path: _FdOrPathType, *, follow_symlinks: bool = ...) -> List[str]: ... # Linux only def removexattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> None: ... # Linux only