Skip to content

Commit

Permalink
Merge pull request #435 from FFY00/fix-mypy
Browse files Browse the repository at this point in the history
Sync PackageMetadata with email.message.Message
  • Loading branch information
jaraco committed Mar 18, 2023
2 parents 5475a6e + a046b04 commit b944c37
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,10 @@
v6.0.1
======

* #434: Expand protocol for ``PackageMetadata.get_all`` to match
the upstream implementation of ``email.message.Message.get_all``
in python/typeshed#9620.

v6.0.0
======

Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Expand Up @@ -61,9 +61,11 @@
),
)

# Workaround for #316
nitpick_ignore = [
# Workaround for #316
('py:class', 'importlib_metadata.EntryPoints'),
('py:class', 'importlib_metadata.SelectableGroups'),
('py:class', 'importlib_metadata._meta._T'),
# Workaround for #435
('py:class', '_T'),
]
10 changes: 8 additions & 2 deletions importlib_metadata/_meta.py
@@ -1,5 +1,5 @@
from ._compat import Protocol
from typing import Any, Dict, Iterator, List, TypeVar, Union
from typing import Any, Dict, Iterator, List, Optional, TypeVar, Union, overload


_T = TypeVar("_T")
Expand All @@ -18,7 +18,13 @@ def __getitem__(self, key: str) -> str:
def __iter__(self) -> Iterator[str]:
... # pragma: no cover

def get_all(self, name: str, failobj: _T = ...) -> Union[List[Any], _T]:
# 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.
"""
Expand Down

0 comments on commit b944c37

Please sign in to comment.