Skip to content

Commit 5ddd122

Browse files
committed
Expand the documentation of Distribution.locate_file to explain why 'locate_file' does what it does and what the consequences are of not implementing it.
Ref pypa/pip#11684
1 parent 3f6acea commit 5ddd122

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

importlib_metadata/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,17 @@ def locate_file(self, path: str | os.PathLike[str]) -> SimplePath:
373373
"""
374374
Given a path to a file in this distribution, return a SimplePath
375375
to it.
376+
377+
This method is used by callers of ``Distribution.files()`` to
378+
locate files within the distribution. If it's possible for a
379+
Distribution to represent files in the distribution as
380+
``SimplePath`` objects, it should implement this method
381+
to resolve such objects.
382+
383+
Some Distribution providers may elect not to resolve SimplePath
384+
objects within the distribution by raising a
385+
NotImplementedError, but consumers of such a Distribution would
386+
be unable to invoke ``Distribution.files()``.
376387
"""
377388

378389
@classmethod

0 commit comments

Comments
 (0)