From 7eca3f5661bb7624139d629c097167c82ce4692c Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 4 Oct 2022 15:53:01 +0100 Subject: [PATCH] Remove Extension.extras The behavior of the 'EntryPoint.extras` attribute that this exposes has changed in recent versions of 'importlib_metadata'/'importlib.metadata'. In change Iff536d4f4267efbebc4be1e7e5da8a9fde39f79b we applied a temporary fix to preserve the legacy behavior on these newer versions, however, given that this is actually a deprecated attribute [1], the best long-term option seems to be not exposing things. Do just that. [1] https://packaging.python.org/en/latest/specifications/entry-points/#data-model Change-Id: Id772d9f002e6945666685138bdef8f8ca32b5229 Signed-off-by: Stephen Finucane --- ...ion-extras-attribute-c2c542c9a4dcd304.yaml | 7 ++++++ stevedore/extension.py | 23 ------------------- stevedore/tests/test_extension.py | 4 ---- 3 files changed, 7 insertions(+), 27 deletions(-) create mode 100644 releasenotes/notes/remove-extension-extras-attribute-c2c542c9a4dcd304.yaml diff --git a/releasenotes/notes/remove-extension-extras-attribute-c2c542c9a4dcd304.yaml b/releasenotes/notes/remove-extension-extras-attribute-c2c542c9a4dcd304.yaml new file mode 100644 index 0000000..c2a6e7c --- /dev/null +++ b/releasenotes/notes/remove-extension-extras-attribute-c2c542c9a4dcd304.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + The ``stevedore.extension.Extension`` object no longer exposes an + ``extras`` attribute. Entry point extras are a deprecated concept that + aren't useful in the context of stevedore thus the value in exposing this + is minimal to none. diff --git a/stevedore/extension.py b/stevedore/extension.py index d9ee084..9db769f 100644 --- a/stevedore/extension.py +++ b/stevedore/extension.py @@ -58,29 +58,6 @@ class Extension(object): match = self.entry_point.pattern.match(self.entry_point.value) return match.group('module') - @property - def extras(self): - """The 'extras' settings for the plugin.""" - # NOTE: The underlying package returned re.Match objects until this was - # fixed in importlib-metadata 4.11.3. This was fixed in Python 3.10 and - # backported to Python 3.9.11. For older versions without this fix, - # translate the re.Match objects to the matched strings, which seem - # more useful. - extras = [] - for extra in self.entry_point.extras: - if isinstance(extra, str): - # We were previously returning the whole string including - # backets. We need to continue doing so to preserve API - # compatibility. - extras.append(f'[{extra}]') - else: - # Python 3.6 returns _sre.SRE_Match objects. Later - # versions of python return re.Match objects. Both types - # have a 'string' attribute containing the text that - # matched the pattern. - extras.append(getattr(extra, 'string', extra)) - return extras - @property def attr(self): """The attribute of the module to be loaded.""" diff --git a/stevedore/tests/test_extension.py b/stevedore/tests/test_extension.py index 7d6c6b8..65af4cb 100644 --- a/stevedore/tests/test_extension.py +++ b/stevedore/tests/test_extension.py @@ -268,10 +268,6 @@ class TestExtensionProperties(utils.TestCase): self.assertEqual('module.name', self.ext1.module_name) self.assertEqual('module', self.ext2.module_name) - def test_extras(self): - self.assertEqual(['[extra]'], self.ext1.extras) - self.assertEqual([], self.ext2.extras) - def test_attr(self): self.assertEqual('attribute.name', self.ext1.attr) self.assertEqual('attribute', self.ext2.attr)