Skip to content

Commit 6202787

Browse files
committed
Expand the docstring for read_text
1 parent d97e389 commit 6202787

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

importlib_metadata/__init__.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,34 @@ def __new__(cls, *args, **kwargs):
356356

357357

358358
class Distribution(DeprecatedNonAbstract):
359-
"""A Python distribution package."""
359+
"""
360+
An abstract Python distribution package.
361+
362+
Custom providers may derive from this class and define
363+
the abstract methods to provide a concrete implementation
364+
for their environment.
365+
"""
360366

361367
@abc.abstractmethod
362368
def read_text(self, filename) -> Optional[str]:
363369
"""Attempt to load metadata file given by the name.
364370
371+
Python distribution metadata is organized by blobs of text
372+
typically represented as "files" in the metadata directory
373+
(e.g. package-1.0.dist-info). These files include things
374+
like:
375+
376+
- METADATA: The distribution metadata including fields
377+
like Name and Version and Description.
378+
- entry_points.txt: A series of entry points defined by
379+
the Setuptools spec in an ini format with sections
380+
representing the groups.
381+
- RECORD: A record of files as installed by a typical
382+
installer.
383+
384+
A package may provide any set of files, including those
385+
not listed here or none at all.
386+
365387
:param filename: The name of the file in the distribution info.
366388
:return: The text if found, otherwise None.
367389
"""
@@ -413,7 +435,7 @@ def discover(
413435

414436
@staticmethod
415437
def at(path: StrPath) -> "Distribution":
416-
"""Return a Distribution for the indicated metadata path
438+
"""Return a Distribution for the indicated metadata path.
417439
418440
:param path: a string or path-like object
419441
:return: a concrete Distribution instance for the path
@@ -422,7 +444,7 @@ def at(path: StrPath) -> "Distribution":
422444

423445
@staticmethod
424446
def _discover_resolvers():
425-
"""Search the meta_path for resolvers."""
447+
"""Search the meta_path for resolvers (MetadataPathFinders)."""
426448
declared = (
427449
getattr(finder, 'find_distributions', None) for finder in sys.meta_path
428450
)

0 commit comments

Comments
 (0)