Sync with importlib_metadata 6.5 (GH-103584)

This commit is contained in:
Jason R. Coombs 2023-04-20 22:12:48 -04:00 committed by GitHub
parent 5c00a6224d
commit 3e0fec7e07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 531 additions and 72 deletions

View file

@ -1,4 +1,5 @@
from typing import Any, Dict, Iterator, List, Protocol, TypeVar, Union
from typing import Protocol
from typing import Any, Dict, Iterator, List, Optional, TypeVar, Union, overload
_T = TypeVar("_T")
@ -17,7 +18,21 @@ class PackageMetadata(Protocol):
def __iter__(self) -> Iterator[str]:
... # pragma: no cover
def get_all(self, name: str, failobj: _T = ...) -> Union[List[Any], _T]:
@overload
def get(self, name: str, failobj: None = None) -> Optional[str]:
... # pragma: no cover
@overload
def get(self, name: str, failobj: _T) -> Union[str, _T]:
... # pragma: no cover
# overload per python/importlib_metadata#435
@overload
def get_all(self, name: str, failobj: None = None) -> Optional[List[Any]]:
... # pragma: no cover
@overload
def get_all(self, name: str, failobj: _T) -> Union[List[Any], _T]:
"""
Return all values associated with a possibly multi-valued key.
"""
@ -29,18 +44,19 @@ class PackageMetadata(Protocol):
"""
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: