MCPcopy Index your code
hub / github.com/python/cpython / from_name

Method from_name

Lib/importlib/metadata/__init__.py:452–467  ·  view source on GitHub ↗

Return the Distribution for the given package name. :param name: The name of the distribution package to search for. :return: The Distribution instance (or subclass thereof) for the named package, if found. :raises PackageNotFoundError: When the named package's d

(cls, name: str)

Source from the content-addressed store, hash-verified

450
451 @classmethod
452 def from_name(cls, name: str) -> Distribution:
453 """Return the Distribution for the given package name.
454
455 :param name: The name of the distribution package to search for.
456 :return: The Distribution instance (or subclass thereof) for the named
457 package, if found.
458 :raises PackageNotFoundError: When the named package's distribution
459 metadata cannot be found.
460 :raises ValueError: When an invalid value is supplied for name.
461 """
462 if not name:
463 raise ValueError("A distribution name is required.")
464 try:
465 return next(iter(cls._prefer_valid(cls.discover(name=name))))
466 except StopIteration:
467 raise PackageNotFoundError(name) from None
468
469 @classmethod
470 def discover(

Callers 9

test_missing_metadataMethod · 0.80
test_originMethod · 0.80
distributionFunction · 0.80
metadataFunction · 0.80

Calls 3

_prefer_validMethod · 0.80
discoverMethod · 0.45