From e16916fedcbeb41ba3e326b9b4fb0b66e660f3bd Mon Sep 17 00:00:00 2001 From: layday Date: Wed, 16 Nov 2022 22:09:56 +0200 Subject: [PATCH 1/2] Fix `SimplePath` protocol This makes `pathlib.Path`s and `zipfile.Path`s assignable to the protocol. --- importlib_metadata/_meta.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/importlib_metadata/_meta.py b/importlib_metadata/_meta.py index 37ee43e6..259b15ba 100644 --- a/importlib_metadata/_meta.py +++ b/importlib_metadata/_meta.py @@ -30,18 +30,19 @@ def json(self) -> Dict[str, Union[str, List[str]]]: """ -class SimplePath(Protocol): +class SimplePath(Protocol[_T]): """ A minimal subset of pathlib.Path required by PathDistribution. """ - def joinpath(self) -> 'SimplePath': + def joinpath(self) -> _T: ... # pragma: no cover - def __truediv__(self) -> 'SimplePath': + def __truediv__(self, other: Union[str, _T]) -> _T: ... # pragma: no cover - def parent(self) -> 'SimplePath': + @property + def parent(self) -> _T: ... # pragma: no cover def read_text(self) -> str: From c7d639e7da133d8ed8027f4c40bf477b8a447459 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 24 Nov 2022 08:52:56 -0500 Subject: [PATCH 2/2] Update changelog. --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 5aa5776f..cf7dcf16 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,8 @@ +v5.1.0 +====== + +* #415: Instrument ``SimplePath`` with generic support. + v5.0.0 ======