Skip to content

Commit

Permalink
Expand the docstring for read_text
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Dec 16, 2023
1 parent d97e389 commit 6202787
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,34 @@ def __new__(cls, *args, **kwargs):


class Distribution(DeprecatedNonAbstract):
"""A Python distribution package."""
"""
An abstract Python distribution package.
Custom providers may derive from this class and define
the abstract methods to provide a concrete implementation
for their environment.
"""

@abc.abstractmethod
def read_text(self, filename) -> Optional[str]:
"""Attempt to load metadata file given by the name.
Python distribution metadata is organized by blobs of text
typically represented as "files" in the metadata directory
(e.g. package-1.0.dist-info). These files include things
like:
- METADATA: The distribution metadata including fields
like Name and Version and Description.
- entry_points.txt: A series of entry points defined by
the Setuptools spec in an ini format with sections
representing the groups.
- RECORD: A record of files as installed by a typical
installer.
A package may provide any set of files, including those
not listed here or none at all.
:param filename: The name of the file in the distribution info.
:return: The text if found, otherwise None.
"""
Expand Down Expand Up @@ -413,7 +435,7 @@ def discover(

@staticmethod
def at(path: StrPath) -> "Distribution":
"""Return a Distribution for the indicated metadata path
"""Return a Distribution for the indicated metadata path.
:param path: a string or path-like object
:return: a concrete Distribution instance for the path
Expand All @@ -422,7 +444,7 @@ def at(path: StrPath) -> "Distribution":

@staticmethod
def _discover_resolvers():
"""Search the meta_path for resolvers."""
"""Search the meta_path for resolvers (MetadataPathFinders)."""
declared = (
getattr(finder, 'find_distributions', None) for finder in sys.meta_path
)
Expand Down

0 comments on commit 6202787

Please sign in to comment.