Skip to content

Commit 2d0493f

Browse files
committed
Merge branch 'feature/better-custom-finders' into 'master'
Provide better clarity on creating custom finders Closes #105 See merge request python-devs/importlib_metadata!104
2 parents d9a5f95 + b54050b commit 2d0493f

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

importlib_metadata/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,21 @@ class DistributionFinder(MetaPathFinder):
359359
"""
360360

361361
class Context:
362+
"""
363+
Keyword arguments presented by the caller to
364+
``distributions()`` or ``Distribution.discover()``
365+
to narrow the scope of a search for distributions
366+
in all DistributionFinders.
367+
368+
Each DistributionFinder may expect any parameters
369+
and should attempt to honor the canonical
370+
parameters defined below when appropriate.
371+
"""
362372

363373
name = None
364374
"""
365375
Specific name for which a distribution finder should match.
376+
A name of ``None`` matches all distributions.
366377
"""
367378

368379
def __init__(self, **kwargs):
@@ -372,6 +383,9 @@ def __init__(self, **kwargs):
372383
def path(self):
373384
"""
374385
The path that a distribution finder should search.
386+
387+
Typically refers to Python package paths and defaults
388+
to ``sys.path``.
375389
"""
376390
return vars(self).get('path', sys.path)
377391

importlib_metadata/docs/using.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ properties indicating the path to search and names to match and may
232232
supply other relevant context.
233233

234234
What this means in practice is that to support finding distribution package
235-
metadata in locations other than the file system, you should derive from
236-
``Distribution`` and implement the ``load_metadata()`` method. Then from
237-
your finder, return instances of this derived ``Distribution`` in the
235+
metadata in locations other than the file system, subclass
236+
``Distribution`` and implement the abstract methods. Then from
237+
a custom finder, return instances of this derived ``Distribution`` in the
238238
``find_distributions()`` method.
239239

240240

0 commit comments

Comments
 (0)