Skip to content

Commit

Permalink
Merge branch 'main' into ghpython-93259/from-name-arg-validation-simple
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco authored Jun 25, 2022
2 parents eb19c64 + f52757d commit c96dc1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 3 additions & 6 deletions importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,9 @@ def from_name(cls, name: str):
"""
if not name:
raise ValueError("A distribution name is required.")
for resolver in cls._discover_resolvers():
dists = resolver(DistributionFinder.Context(name=name))
dist = next(iter(dists), None)
if dist is not None:
return dist
else:
try:
return next(cls.discover(name=name))
except StopIteration:
raise PackageNotFoundError(name)

@classmethod
Expand Down
1 change: 1 addition & 0 deletions importlib_metadata/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
try:
from typing import Protocol
except ImportError: # pragma: no cover
# Python 3.7 compatibility
from typing_extensions import Protocol # type: ignore


Expand Down

0 comments on commit c96dc1e

Please sign in to comment.