From 1a2c6ee09d19e7cbd2915bd2470016b6c82d7f3f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Apr 2023 09:08:33 -0400 Subject: [PATCH] Remove the ABC from Distribution. Fixes #422. --- importlib_metadata/__init__.py | 5 ++--- tests/test_main.py | 4 ---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index 96571f4a..0c5085a1 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -348,10 +348,9 @@ def __repr__(self): return f'' -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. @@ -359,12 +358,12 @@ def read_text(self, filename) -> Optional[str]: :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): diff --git a/tests/test_main.py b/tests/test_main.py index 7d6c79a4..254195a2 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -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=''),