diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index 059e3dd69c27..879760016546 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -183,10 +183,7 @@ if sys.version_info >= (3, 6): from builtins import _PathLike as PathLike # See comment in builtins _PathType = path._PathType -if sys.version_info >= (3, 3): - _FdOrPathType = Union[int, _PathType] -else: - _FdOrPathType = _PathType +_FdOrPathType = path._FdOrPathType if sys.version_info >= (3, 6): class DirEntry(PathLike[AnyStr]): diff --git a/stdlib/3/os/path.pyi b/stdlib/3/os/path.pyi index 993d3aa1aaf0..6f3afb09042d 100644 --- a/stdlib/3/os/path.pyi +++ b/stdlib/3/os/path.pyi @@ -17,6 +17,11 @@ if sys.version_info >= (3, 6): else: _PathType = Union[bytes, Text] +if sys.version_info >= (3, 3): + _FdOrPathType = Union[int, _PathType] +else: + _FdOrPathType = _PathType + # ----- os.path variables ----- supports_unicode_filenames = False # aliases (also in os) @@ -42,21 +47,21 @@ if sys.version_info >= (3, 5): def commonprefix(list: Sequence[AnyStr]) -> Any: ... def dirname(path: AnyStr) -> AnyStr: ... -def exists(path: _PathType) -> bool: ... +def exists(path: _FdOrPathType) -> bool: ... def lexists(path: _PathType) -> bool: ... def expanduser(path: AnyStr) -> AnyStr: ... def expandvars(path: AnyStr) -> AnyStr: ... # These return float if os.stat_float_times() == True, # but int is a subclass of float. -def getatime(path: _PathType) -> float: ... -def getmtime(path: _PathType) -> float: ... -def getctime(path: _PathType) -> float: ... +def getatime(path: _FdOrPathType) -> float: ... +def getmtime(path: _FdOrPathType) -> float: ... +def getctime(path: _FdOrPathType) -> float: ... -def getsize(path: _PathType) -> int: ... +def getsize(path: _FdOrPathType) -> int: ... def isabs(path: _PathType) -> bool: ... -def isfile(path: _PathType) -> bool: ... -def isdir(path: _PathType) -> bool: ... +def isfile(path: _FdOrPathType) -> bool: ... +def isdir(path: _FdOrPathType) -> bool: ... def islink(path: _PathType) -> bool: ... def ismount(path: _PathType) -> bool: ... @@ -86,7 +91,7 @@ else: def realpath(filename: AnyStr) -> AnyStr: ... def relpath(path: AnyStr, start: _PathType = ...) -> AnyStr: ... -def samefile(path1: _PathType, path2: _PathType) -> bool: ... +def samefile(path1: _FdOrPathType, path2: _FdOrPathType) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... # TODO # def samestat(stat1: stat_result,