Skip to content

Commit 2180bea

Browse files
committed
Add a paragraph describing why context.path is not included in the example.
1 parent 2dd1db7 commit 2180bea

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Doc/library/importlib.metadata.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,23 @@ custom importer to provide metadata, it would also need to implement
427427
for dist_record in self.db.query_distributions(query):
428428
yield DatabaseDistribution(dist_record)
429429

430-
431430
In this way, ``query_distributions`` would return records for
432431
each distribution served by the database matching the query. For
433432
example, if ``requests-1.0`` is in the database, ``find_distributions``
434433
would yield a ``DatabaseDistribution`` for ``Context(name='requests')``
435434
or ``Context(name=None)``.
436435

436+
For the sake of simplicity, this example ignores ``context.path``. The
437+
``path`` attribute defaults to ``sys.path`` and is the set of import paths to
438+
be considered in the search. A ``DatabaseImporter`` could potentially function
439+
without any concern for a search path. Assuming the importer does no
440+
partitioning, the "path" would be irrelevant. In order to illustrate the
441+
purpose of ``path``, the example would need to illustrate a more complex
442+
``DatabaseImporter`` whose behavior varied depending on
443+
``sys.path``/``PYTHONPATH``. In that case, the ``find_distributions`` should
444+
honor the ``context.path`` and only yield ``Distribution``s pertinent to that
445+
path.
446+
437447
``DatabaseDistribution``, then, would look something like::
438448

439449
class DatabaseDistribution(importlib.metadata.Distributon):

0 commit comments

Comments
 (0)