summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/metadata/_meta.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-05-02 21:03:40 (GMT)
committerGitHub <noreply@github.com>2021-05-02 21:03:40 (GMT)
commit37e0c7850de902179b28f1378fbbc38a5ed3628c (patch)
treeecc352d5d7eaf99485bc4c2735d2a5f14f532084 /Lib/importlib/metadata/_meta.py
parent0ad1e0384c8afc5259a6d03363491d89500a5d03 (diff)
downloadcpython-37e0c7850de902179b28f1378fbbc38a5ed3628c.zip
cpython-37e0c7850de902179b28f1378fbbc38a5ed3628c.tar.gz
cpython-37e0c7850de902179b28f1378fbbc38a5ed3628c.tar.bz2
bpo-43926: Cleaner metadata with PEP 566 JSON support. (GH-25565)
* bpo-43926: Cleaner metadata with PEP 566 JSON support. * Add blurb * Add versionchanged and versionadded declarations for changes to metadata. * Use descriptor for PEP 566
Diffstat (limited to 'Lib/importlib/metadata/_meta.py')
-rw-r--r--Lib/importlib/metadata/_meta.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/importlib/metadata/_meta.py b/Lib/importlib/metadata/_meta.py
new file mode 100644
index 0000000..04d9a02
--- /dev/null
+++ b/Lib/importlib/metadata/_meta.py
@@ -0,0 +1,29 @@
+from typing import Any, Dict, Iterator, List, Protocol, TypeVar, Union
+
+
+_T = TypeVar("_T")
+
+
+class PackageMetadata(Protocol):
+ def __len__(self) -> int:
+ ... # pragma: no cover
+
+ def __contains__(self, item: str) -> bool:
+ ... # pragma: no cover
+
+ def __getitem__(self, key: str) -> str:
+ ... # pragma: no cover
+
+ def __iter__(self) -> Iterator[str]:
+ ... # pragma: no cover
+
+ def get_all(self, name: str, failobj: _T = ...) -> Union[List[Any], _T]:
+ """
+ Return all values associated with a possibly multi-valued key.
+ """
+
+ @property
+ def json(self) -> Dict[str, Union[str, List[str]]]:
+ """
+ A JSON-compatible form of the metadata.
+ """