Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync PackageMetadata with email.message.Message #435

Merged
merged 5 commits into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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