From ffba2ea87ad638cbc7b5464569d369c540133d50 Mon Sep 17 00:00:00 2001 From: Froger David Date: Tue, 5 Jun 2018 23:02:46 +0200 Subject: [PATCH] compile builtin accept PathLike (#2200) --- stdlib/3/builtins.pyi | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index d73f40112..9cb473410 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -805,7 +805,15 @@ if sys.version_info >= (3, 7): def breakpoint(*args: Any, **kws: Any) -> None: ... def callable(o: object) -> bool: ... def chr(code: int) -> str: ... -def compile(source: Any, filename: Union[str, bytes], mode: str, flags: int = ..., dont_inherit: int = ...) -> CodeType: ... +if sys.version_info >= (3, 6): + # This class is to be exported as PathLike from os, + # but we define it here as _PathLike to avoid import cycle issues. + # See https://github.com/python/typeshed/pull/991#issuecomment-288160993 + class _PathLike(Generic[AnyStr]): + def __fspath__(self) -> AnyStr: ... + def compile(source: Any, filename: Union[str, bytes, _PathLike], mode: str, flags: int = ..., dont_inherit: int = ...) -> CodeType: ... +else: + def compile(source: Any, filename: Union[str, bytes], mode: str, flags: int = ..., dont_inherit: int = ...) -> CodeType: ... def copyright() -> None: ... def credits() -> None: ... def delattr(o: Any, name: str) -> None: ... @@ -884,12 +892,6 @@ def next(i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(i: int) -> str: ... # TODO __index__ if sys.version_info >= (3, 6): - # This class is to be exported as PathLike from os, - # but we define it here as _PathLike to avoid import cycle issues. - # See https://github.com/python/typeshed/pull/991#issuecomment-288160993 - class _PathLike(Generic[AnyStr]): - def __fspath__(self) -> AnyStr: ... - def open(file: Union[str, bytes, int, _PathLike], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., newline: Optional[str] = ..., closefd: bool = ...) -> IO[Any]: ... else: