Skip to content

Commit 8f97677

Browse files
author
hauntsaninja
committed
PathLike: change to Protocol
1 parent 0ee7b26 commit 8f97677

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

stdlib/2/__builtin__.pyi

+3-2
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,9 @@ if sys.version_info >= (3, 6):
12071207
# This class is to be exported as PathLike from os,
12081208
# but we define it here as _PathLike to avoid import cycle issues.
12091209
# See https://github.com/python/typeshed/pull/991#issuecomment-288160993
1210-
class _PathLike(Generic[AnyStr]):
1211-
def __fspath__(self) -> AnyStr: ...
1210+
AnyStr_co = TypeVar("AnyStr_co", str, bytes, covariant=True)
1211+
class _PathLike(Protocol[AnyStr_co]):
1212+
def __fspath__(self) -> AnyStr_co: ...
12121213
def compile(
12131214
source: Union[str, bytes, mod, AST],
12141215
filename: Union[str, bytes, _PathLike[Any]],

stdlib/2and3/builtins.pyi

+3-2
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,9 @@ if sys.version_info >= (3, 6):
12071207
# This class is to be exported as PathLike from os,
12081208
# but we define it here as _PathLike to avoid import cycle issues.
12091209
# See https://github.com/python/typeshed/pull/991#issuecomment-288160993
1210-
class _PathLike(Generic[AnyStr]):
1211-
def __fspath__(self) -> AnyStr: ...
1210+
AnyStr_co = TypeVar("AnyStr_co", str, bytes, covariant=True)
1211+
class _PathLike(Protocol[AnyStr_co]):
1212+
def __fspath__(self) -> AnyStr_co: ...
12121213
def compile(
12131214
source: Union[str, bytes, mod, AST],
12141215
filename: Union[str, bytes, _PathLike[Any]],

stdlib/3/os/__init__.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ if sys.version_info >= (3, 6):
265265
_FdOrAnyPath = Union[int, AnyPath]
266266

267267
if sys.version_info >= (3, 6):
268-
class DirEntry(PathLike[AnyStr]):
268+
class DirEntry(Generic[AnyStr]):
269269
# This is what the scandir interator yields
270270
# The constructor is hidden
271271

0 commit comments

Comments
 (0)