_meta.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from ._compat import Protocol
  2. from typing import Any, Dict, Iterator, List, TypeVar, Union
  3. _T = TypeVar("_T")
  4. class PackageMetadata(Protocol):
  5. def __len__(self) -> int:
  6. ... # pragma: no cover
  7. def __contains__(self, item: str) -> bool:
  8. ... # pragma: no cover
  9. def __getitem__(self, key: str) -> str:
  10. ... # pragma: no cover
  11. def __iter__(self) -> Iterator[str]:
  12. ... # pragma: no cover
  13. def get_all(self, name: str, failobj: _T = ...) -> Union[List[Any], _T]:
  14. """
  15. Return all values associated with a possibly multi-valued key.
  16. """
  17. @property
  18. def json(self) -> Dict[str, Union[str, List[str]]]:
  19. """
  20. A JSON-compatible form of the metadata.
  21. """
  22. class SimplePath(Protocol):
  23. """
  24. A minimal subset of pathlib.Path required by PathDistribution.
  25. """
  26. def joinpath(self) -> 'SimplePath':
  27. ... # pragma: no cover
  28. def __truediv__(self) -> 'SimplePath':
  29. ... # pragma: no cover
  30. def parent(self) -> 'SimplePath':
  31. ... # pragma: no cover
  32. def read_text(self) -> str:
  33. ... # pragma: no cover