Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the ABC from Distribution #448

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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