Skip to content

Commit c96dc1e

Browse files
authored
Merge branch 'main' into ghpython-93259/from-name-arg-validation-simple
2 parents eb19c64 + f52757d commit c96dc1e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

importlib_metadata/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,9 @@ def from_name(cls, name: str):
560560
"""
561561
if not name:
562562
raise ValueError("A distribution name is required.")
563-
for resolver in cls._discover_resolvers():
564-
dists = resolver(DistributionFinder.Context(name=name))
565-
dist = next(iter(dists), None)
566-
if dist is not None:
567-
return dist
568-
else:
563+
try:
564+
return next(cls.discover(name=name))
565+
except StopIteration:
569566
raise PackageNotFoundError(name)
570567

571568
@classmethod

importlib_metadata/_compat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
try:
99
from typing import Protocol
1010
except ImportError: # pragma: no cover
11+
# Python 3.7 compatibility
1112
from typing_extensions import Protocol # type: ignore
1213

1314

0 commit comments

Comments
 (0)