Skip to content

Commit b944c37

Browse files
authored
Merge pull request #435 from FFY00/fix-mypy
Sync PackageMetadata with email.message.Message
2 parents 5475a6e + a046b04 commit b944c37

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

CHANGES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v6.0.1
2+
======
3+
4+
* #434: Expand protocol for ``PackageMetadata.get_all`` to match
5+
the upstream implementation of ``email.message.Message.get_all``
6+
in python/typeshed#9620.
7+
18
v6.0.0
29
======
310

docs/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@
6161
),
6262
)
6363

64-
# Workaround for #316
6564
nitpick_ignore = [
65+
# Workaround for #316
6666
('py:class', 'importlib_metadata.EntryPoints'),
6767
('py:class', 'importlib_metadata.SelectableGroups'),
6868
('py:class', 'importlib_metadata._meta._T'),
69+
# Workaround for #435
70+
('py:class', '_T'),
6971
]

importlib_metadata/_meta.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ._compat import Protocol
2-
from typing import Any, Dict, Iterator, List, TypeVar, Union
2+
from typing import Any, Dict, Iterator, List, Optional, TypeVar, Union, overload
33

44

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

21-
def get_all(self, name: str, failobj: _T = ...) -> Union[List[Any], _T]:
21+
# overload per python/importlib_metadata#435
22+
@overload
23+
def get_all(self, name: str, failobj: None = None) -> Optional[List[Any]]:
24+
... # pragma: no cover
25+
26+
@overload
27+
def get_all(self, name: str, failobj: _T) -> Union[List[Any], _T]:
2228
"""
2329
Return all values associated with a possibly multi-valued key.
2430
"""

0 commit comments

Comments
 (0)