Merge pull request #991 from JetBrains/sproshev/pep-519

Update `open`, `os.fspath`, `os.fsencode`, `os.fsdecode`, `pathlib.PurePath` and `pathlib.Path` stubs due to PEP-519
This commit is contained in:
Jelle Zijlstra
2017-03-21 07:38:50 -07:00
committed by GitHub
3 changed files with 29 additions and 7 deletions

View File

@@ -799,8 +799,8 @@ def next(i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ...
def oct(i: int) -> str: ... # TODO __index__
if sys.version_info >= (3, 6):
from pathlib import Path
def open(file: Union[str, bytes, int, Path], mode: str = 'r', buffering: int = -1, encoding: str = None,
from os import PathLike
def open(file: Union[str, bytes, int, PathLike], mode: str = 'r', buffering: int = -1, encoding: str = None,
errors: str = None, newline: str = None, closefd: bool = ...) -> IO[Any]: ...
else:
def open(file: Union[str, bytes, int], mode: str = 'r', buffering: int = -1, encoding: str = None,

View File

@@ -189,8 +189,24 @@ class statvfs_result: # Unix only
f_namemax = 0
# ----- os function stubs -----
def fsencode(filename: str) -> bytes: ...
def fsdecode(filename: bytes) -> str: ...
if sys.version_info >= (3, 6):
def fsencode(filename: Union[str, bytes, PathLike]) -> bytes: ...
else:
def fsencode(filename: Union[str, bytes]) -> bytes: ...
if sys.version_info >= (3, 6):
def fsdecode(filename: Union[str, bytes, PathLike]) -> str: ...
else:
def fsdecode(filename: Union[str, bytes]) -> str: ...
if sys.version_info >= (3, 6):
@overload
def fspath(path: str) -> str: ...
@overload
def fspath(path: bytes) -> bytes: ...
@overload
def fspath(path: PathLike) -> Any: ...
def get_exec_path(env: Optional[Mapping[str, str]] = ...) -> List[str]: ...
# NOTE: get_exec_path(): returns List[bytes] when env not None
def ctermid() -> str: ... # Unix only