builtins: minor improvements (#4535)

Co-authored-by: hauntsaninja <>
This commit is contained in:
Shantanu
2020-09-13 09:08:48 -07:00
committed by GitHub
parent 0f69275ce4
commit dc0b4262c3
2 changed files with 46 additions and 18 deletions

View File

@@ -1207,13 +1207,27 @@ if sys.version_info < (3,):
_N1 = TypeVar("_N1", bool, int, float, complex)
def coerce(__x: _N1, __y: _N1) -> Tuple[_N1, _N1]: ...
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
_AnyStr_co = TypeVar("_AnyStr_co", str, bytes, covariant=True)
class _PathLike(Protocol[_AnyStr_co]):
def __fspath__(self) -> _AnyStr_co: ...
# 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
_AnyStr_co = TypeVar("_AnyStr_co", str, bytes, covariant=True)
class _PathLike(Protocol[_AnyStr_co]):
def __fspath__(self) -> _AnyStr_co: ...
if sys.version_info >= (3, 8):
def compile(
source: Union[str, bytes, mod, AST],
filename: Union[str, bytes, _PathLike[Any]],
mode: str,
flags: int = ...,
dont_inherit: int = ...,
optimize: int = ...,
*,
_feature_version: int = ...,
) -> Any: ...
elif sys.version_info >= (3, 6):
def compile(
source: Union[str, bytes, mod, AST],
filename: Union[str, bytes, _PathLike[Any]],
@@ -1624,9 +1638,9 @@ if sys.version_info < (3,):
def reload(__module: Any) -> Any: ...
@overload
def reversed(__object: Sequence[_T]) -> Iterator[_T]: ...
def reversed(__sequence: Sequence[_T]) -> Iterator[_T]: ...
@overload
def reversed(__object: Reversible[_T]) -> Iterator[_T]: ...
def reversed(__sequence: Reversible[_T]) -> Iterator[_T]: ...
def repr(__obj: object) -> str: ...
if sys.version_info >= (3,):