PathLike cleanup (#5242)

Copy builtins._PathLike to os.PathLike

Use os.PathLike exclusively outside of builtins
This commit is contained in:
Sebastian Rittau
2021-04-23 19:15:07 +02:00
committed by GitHub
parent 27facc7ff9
commit bac1918b5f
14 changed files with 83 additions and 117 deletions

View File

@@ -57,7 +57,6 @@ from typing import (
Union,
ValuesView,
overload,
runtime_checkable,
)
from typing_extensions import Literal, SupportsIndex
@@ -959,11 +958,10 @@ if sys.version_info >= (3, 7):
def callable(__obj: object) -> bool: ...
def chr(__i: int) -> str: ...
# This class is to be exported as PathLike from os,
# but we define it here as _PathLike to avoid import cycle issues.
# We define this here instead of using os.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)
@runtime_checkable
class _PathLike(Protocol[_AnyStr_co]):
def __fspath__(self) -> _AnyStr_co: ...