Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/5234.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`opentelemetry-api`: avoid deprecated `SelectableGroups` dict access.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
def _as_entry_points(eps: Any) -> EntryPoints:
if isinstance(eps, EntryPoints):
return eps
if hasattr(eps, "select"):
return eps.select()
# Handle Python 3.10 SelectableGroups (dict-like)
return EntryPoints(ep for group_eps in eps.values() for ep in group_eps)

Expand Down
15 changes: 15 additions & 0 deletions opentelemetry-api/tests/util/test__importlib_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,18 @@ def test_as_entry_points_selectable_groups_compat(self):
self.assertIsInstance(normalized, EntryPoints)
self.assertEqual(len(normalized), 2)
self.assertEqual(list(normalized), [ep1, ep2])

def test_as_entry_points_uses_selectable_groups_select(self):
"""Test that SelectableGroups are normalized without the deprecated dict API."""
entry_point = EntryPoint(name="foo", value="bar:baz", group="gp")

class SelectableGroups:
def select(self):
return EntryPoints([entry_point])

def values(self):
raise AssertionError("deprecated dict interface used")

normalized = _as_entry_points(SelectableGroups())
self.assertIsInstance(normalized, EntryPoints)
self.assertEqual(list(normalized), [entry_point])