Skip to content

Commit

Permalink
Remove the ABC from Distribution. Fixes #422.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 14, 2023
1 parent d390898 commit 1a2c6ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 2 additions & 3 deletions importlib_metadata/__init__.py
Expand Up @@ -348,23 +348,22 @@ def __repr__(self):
return f'<FileHash mode: {self.mode} value: {self.value}>'


class Distribution(metaclass=abc.ABCMeta):
class Distribution:
"""A Python distribution package."""

@abc.abstractmethod
def read_text(self, filename) -> Optional[str]:
"""Attempt to load metadata file given by the name.
:param filename: The name of the file in the distribution info.
:return: The text if found, otherwise None.
"""

@abc.abstractmethod
def locate_file(self, path):
"""
Given a path to a file in this distribution, return a path
to it.
"""
raise NotImplementedError

@classmethod
def from_name(cls, name: str):
Expand Down
4 changes: 0 additions & 4 deletions tests/test_main.py
Expand Up @@ -44,10 +44,6 @@ def test_package_not_found_mentions_metadata(self):

assert "metadata" in str(ctx.exception)

def test_abc_enforced(self):
with self.assertRaises(TypeError):
type('DistributionSubclass', (Distribution,), {})()

@fixtures.parameterize(
dict(name=None),
dict(name=''),
Expand Down

0 comments on commit 1a2c6ee

Please sign in to comment.