From a8aacb0c6f2f06bf19b501d98e62f7c0e667fa4c Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Wed, 11 Sep 2024 16:55:35 -0600 Subject: [PATCH] Add more symbols to opentelemetry.util._importlib_metadata (#4181) Fixes #4180 --- .../opentelemetry/util/_importlib_metadata.py | 20 +++++++++++++------ .../tests/util/test__importlib_metadata.py | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py b/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py index cbf09f3ef8c..2457630ba22 100644 --- a/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py +++ b/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py @@ -15,15 +15,23 @@ # FIXME: Use importlib.metadata when support for 3.11 is dropped if the rest of # the supported versions at that time have the same API. from importlib_metadata import ( # type: ignore + Distribution, EntryPoint, EntryPoints, + PackageNotFoundError, + distributions, entry_points, + requires, version, ) -# The importlib-metadata library has introduced breaking changes before to its -# API, this module is kept just to act as a layer between the -# importlib-metadata library and our project if in any case it is necessary to -# do so. - -__all__ = ["entry_points", "version", "EntryPoint", "EntryPoints"] +__all__ = [ + "entry_points", + "version", + "EntryPoint", + "EntryPoints", + "requires", + "Distribution", + "distributions", + "PackageNotFoundError", +] diff --git a/opentelemetry-api/tests/util/test__importlib_metadata.py b/opentelemetry-api/tests/util/test__importlib_metadata.py index 92a4e7dd62a..dce949c47d8 100644 --- a/opentelemetry-api/tests/util/test__importlib_metadata.py +++ b/opentelemetry-api/tests/util/test__importlib_metadata.py @@ -19,6 +19,7 @@ from opentelemetry.util._importlib_metadata import ( entry_points as importlib_metadata_entry_points, ) +from opentelemetry.util._importlib_metadata import version class TestEntryPoints(TestCase): @@ -106,3 +107,5 @@ def test_uniform_behavior(self): entry_points = importlib_metadata_entry_points(group="abc", name="abc") self.assertIsInstance(entry_points, EntryPoints) self.assertEqual(len(entry_points), 0) + + self.assertIsInstance(version("opentelemetry-api"), str)