Skip to content

Commit

Permalink
Add ABCMeta to Distribution. Fixes #419.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 1, 2023
1 parent 1bf8a7a commit 8a9d169
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def __repr__(self):
return f'<FileHash mode: {self.mode} value: {self.value}>'


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

@abc.abstractmethod
Expand Down
5 changes: 2 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ def test_package_not_found_mentions_metadata(self):
assert "metadata" in str(ctx.exception)

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

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

0 comments on commit 8a9d169

Please sign in to comment.