Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd0616a8

Browse files
committed
meta: add Path protocol for PathDistribution
This is needed to properly annotate code that uses PathDistribution,otherwise I need to keep redefining the protocol in my code.Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parente99cd3c commitd0616a8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎importlib_metadata/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
importcollections
1616

1717
from .import_adapters,_meta
18-
from ._metaimportPackageMetadata
18+
from ._metaimportPackageMetadata,Path
1919
from ._collectionsimportFreezableDefaultDict,Pair
2020
from ._compatimport (
2121
NullFinder,
@@ -783,7 +783,7 @@ def invalidate_caches(cls):
783783

784784

785785
classPathDistribution(Distribution):
786-
def__init__(self,path):
786+
def__init__(self,path:Path):
787787
"""Construct a distribution from a path to the metadata directory.
788788
789789
:param path: A pathlib.Path or similar object supporting

‎importlib_metadata/_meta.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,16 @@ def json(self) -> Dict[str, Union[str, List[str]]]:
2828
"""
2929
A JSON-compatible form of the metadata.
3030
"""
31+
32+
classPath(Protocol):
33+
defjoinpath(self)->'Path':
34+
...# pragma: no cover
35+
36+
def__div__(self)->'Path':
37+
...# pragma: no cover
38+
39+
defparent(self)->'Path':
40+
...# pragma: no cover
41+
42+
defread_text(self)->str:
43+
...# pragma: no cover

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp