mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-28 14:46:55 +08:00
Merge stdlib/{2,3}/os/path.pyi (#1150)
* Merge stdlib/{2,3}/os/path.pyi
To be renamed into stdlib/2and3/os/path.pyi later.
Also fixes #50
* CR fixes
This commit is contained in:
committed by
Jelle Zijlstra
parent
aa0d0d152e
commit
26360e821b
@@ -3,8 +3,14 @@
|
||||
|
||||
# based on http://docs.python.org/3.2/library/os.path.html
|
||||
# adapted for 2.7 by Michal Pokorny
|
||||
import sys
|
||||
from typing import (
|
||||
overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO,
|
||||
TypeVar, Union, Text, Callable
|
||||
)
|
||||
|
||||
from typing import overload, List, Any, Tuple, BinaryIO, TextIO, TypeVar, Callable, AnyStr
|
||||
_T = TypeVar('_T')
|
||||
_PathType = Union[bytes, Text]
|
||||
|
||||
# ----- os.path variables -----
|
||||
supports_unicode_filenames = False
|
||||
@@ -22,25 +28,32 @@ devnull = ... # type: str
|
||||
def abspath(path: AnyStr) -> AnyStr: ...
|
||||
def basename(path: AnyStr) -> AnyStr: ...
|
||||
|
||||
def commonprefix(list: List[AnyStr]) -> AnyStr: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ...
|
||||
|
||||
# NOTE: Empty lists results in '' (str) regardless of contained type.
|
||||
# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes
|
||||
# So, fall back to Any
|
||||
def commonprefix(list: Sequence[AnyStr]) -> Any: ...
|
||||
|
||||
def dirname(path: AnyStr) -> AnyStr: ...
|
||||
def exists(path: unicode) -> bool: ...
|
||||
def lexists(path: unicode) -> bool: ...
|
||||
def exists(path: _PathType) -> 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: unicode) -> float: ...
|
||||
def getmtime(path: unicode) -> float: ...
|
||||
def getctime(path: unicode) -> float: ...
|
||||
def getatime(path: _PathType) -> float: ...
|
||||
def getmtime(path: _PathType) -> float: ...
|
||||
def getctime(path: _PathType) -> float: ...
|
||||
|
||||
def getsize(path: unicode) -> int: ...
|
||||
def isabs(path: unicode) -> bool: ...
|
||||
def isfile(path: unicode) -> bool: ...
|
||||
def isdir(path: unicode) -> bool: ...
|
||||
def islink(path: unicode) -> bool: ...
|
||||
def ismount(path: unicode) -> bool: ...
|
||||
def getsize(path: _PathType) -> int: ...
|
||||
def isabs(path: _PathType) -> bool: ...
|
||||
def isfile(path: _PathType) -> bool: ...
|
||||
def isdir(path: _PathType) -> bool: ...
|
||||
def islink(path: _PathType) -> bool: ...
|
||||
def ismount(path: _PathType) -> bool: ...
|
||||
|
||||
def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ...
|
||||
|
||||
@@ -49,7 +62,7 @@ def normpath(path: AnyStr) -> AnyStr: ...
|
||||
def realpath(path: AnyStr) -> AnyStr: ...
|
||||
def relpath(path: AnyStr, start: AnyStr = ...) -> AnyStr: ...
|
||||
|
||||
def samefile(path1: unicode, path2: unicode) -> bool: ...
|
||||
def samefile(path1: _PathType, path2: _PathType) -> bool: ...
|
||||
def sameopenfile(fp1: int, fp2: int) -> bool: ...
|
||||
# TODO
|
||||
# def samestat(stat1: stat_result,
|
||||
@@ -61,5 +74,5 @@ def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
|
||||
|
||||
def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # Windows only, deprecated
|
||||
|
||||
_T = TypeVar('_T')
|
||||
def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ...
|
||||
if sys.version_info < (3,):
|
||||
def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user