Skip to content

Commit 482f207

Browse files
JelleZijlstragvanrossum
authored andcommitted
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.
1 parent d24799f commit 482f207

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

stdlib/3/os/__init__.pyi

+17-3
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,23 @@ else:
512512
followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr],
513513
List[AnyStr]]]: ...
514514
if sys.version_info >= (3, 3):
515-
def fwalk(top: _PathType = ..., topdown: bool = ...,
516-
onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ...,
517-
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only
515+
if sys.version_info >= (3, 7):
516+
@overload
517+
def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ...,
518+
onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ...,
519+
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only
520+
@overload
521+
def fwalk(top: bytes, topdown: bool = ...,
522+
onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ...,
523+
dir_fd: Optional[int] = ...) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ... # Unix only
524+
elif sys.version_info >= (3, 6):
525+
def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ...,
526+
onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ...,
527+
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only
528+
else:
529+
def fwalk(top: str = ..., topdown: bool = ...,
530+
onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ...,
531+
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only
518532
def getxattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> bytes: ... # Linux only
519533
def listxattr(path: _FdOrPathType, *, follow_symlinks: bool = ...) -> List[str]: ... # Linux only
520534
def removexattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> None: ... # Linux only

0 commit comments

Comments
 (0)