Skip to content

Commit e27d079

Browse files
committed
Move docstrings about interface to the protocol. Rename to SimplePath to easily distinguish. Add changelog.
1 parent 38350dc commit e27d079

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
v4.1.0
2+
=======
3+
4+
* #315: Add ``SimplePath`` protocol for interface clarity
5+
in ``PathDistribution``.
6+
17
v4.0.1
28
=======
39

importlib_metadata/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424
from ._functools import method_cache
2525
from ._itertools import unique_everseen
26-
from ._meta import PackageMetadata, Path
26+
from ._meta import PackageMetadata, SimplePath
2727

2828
from contextlib import suppress
2929
from importlib import import_module
@@ -783,11 +783,10 @@ def invalidate_caches(cls):
783783

784784

785785
class PathDistribution(Distribution):
786-
def __init__(self, path: Path):
787-
"""Construct a distribution from a path to the metadata directory.
786+
def __init__(self, path: SimplePath):
787+
"""Construct a distribution.
788788
789-
:param path: A pathlib.Path or similar object supporting
790-
.joinpath(), __div__, .parent, and .read_text().
789+
:param path: SimplePath indicating the metadata directory.
791790
"""
792791
self._path = path
793792

importlib_metadata/_meta.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ def json(self) -> Dict[str, Union[str, List[str]]]:
3030
"""
3131

3232

33-
class Path(Protocol):
34-
def joinpath(self) -> 'Path':
33+
class SimplePath(Protocol):
34+
"""
35+
A minimal subset of pathlib.Path required by PathDistribution.
36+
"""
37+
38+
def joinpath(self) -> 'SimplePath':
3539
... # pragma: no cover
3640

37-
def __div__(self) -> 'Path':
41+
def __div__(self) -> 'SimplePath':
3842
... # pragma: no cover
3943

40-
def parent(self) -> 'Path':
44+
def parent(self) -> 'SimplePath':
4145
... # pragma: no cover
4246

4347
def read_text(self) -> str:

0 commit comments

Comments
 (0)