Skip to content

Commit

Permalink
Add a paragraph describing why context.path is not included in the ex…
Browse files Browse the repository at this point in the history
…ample.
  • Loading branch information
jaraco committed Dec 16, 2023
1 parent 2dd1db7 commit a3af10d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Doc/library/importlib.metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,23 @@ custom importer to provide metadata, it would also need to implement
for dist_record in self.db.query_distributions(query):
yield DatabaseDistribution(dist_record)


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

For the sake of simplicity, this example ignores ``context.path``. The `path`

Check warning on line 436 in Doc/library/importlib.metadata.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

Inline literal start-string without end-string.
attribute defaults to ``sys.path`` and is the set of import paths to be
considered in the search. A ``DatabaseImporter`` could potentially function
without any concern for a search path. Assuming the importer does no
partitioning, the "path" would be irrelevant. In order to illustrate the
purpose of ``path``, the example would need to illustrate a more complex
``DatabaseImporter`` whose behavior varied depending on
``sys.path``/``PYTHONPATH``. In that case, the ``find_distributions`` should
honor the ``context.path`` and only yield ``Distribution``s pertinent to that
path.
``DatabaseDistribution``, then, would look something like::

class DatabaseDistribution(importlib.metadata.Distributon):
Expand Down

0 comments on commit a3af10d

Please sign in to comment.