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

Method discover

Lib/importlib/metadata/__init__.py:470–487  ·  view source on GitHub ↗

Return an iterable of Distribution objects for all packages. Pass a ``context`` or pass keyword arguments for constructing a context. :context: A ``DistributionFinder.Context`` object. :return: Iterable of Distribution objects for packages matching the con

(
        cls, *, context: DistributionFinder.Context | None = None, **kwargs
    )

Source from the content-addressed store, hash-verified

468
469 @classmethod
470 def discover(
471 cls, *, context: DistributionFinder.Context | None = None, **kwargs
472 ) -> Iterable[Distribution]:
473 """Return an iterable of Distribution objects for all packages.
474
475 Pass a ``context`` or pass keyword arguments for constructing
476 a context.
477
478 :context: A ``DistributionFinder.Context`` object.
479 :return: Iterable of Distribution objects for packages matching
480 the context.
481 """
482 if context and kwargs:
483 raise ValueError("cannot accept context and kwargs")
484 context = context or DistributionFinder.Context(**kwargs)
485 return itertools.chain.from_iterable(
486 resolver(context) for resolver in cls._discover_resolvers()
487 )
488
489 @staticmethod
490 def _prefer_valid(dists: Iterable[Distribution]) -> Iterable[Distribution]:

Callers 3

inspectFunction · 0.45
from_nameMethod · 0.45
distributionsFunction · 0.45

Calls 1

_discover_resolversMethod · 0.80

Tested by

no test coverage detected