Avoid SelectableGroups deprecation warning#5238
Open
HasanTasdiq wants to merge 3 commits into
Open
Conversation
Assisted-by: OpenAI Codex
Assisted-by: OpenAI Codex
herin049
reviewed
May 20, 2026
| def _as_entry_points(eps: Any) -> EntryPoints: | ||
| if isinstance(eps, EntryPoints): | ||
| return eps | ||
| if hasattr(eps, "groups") and hasattr(eps, "select"): |
Contributor
There was a problem hiding this comment.
We shouldn't really need this conditional branch here at all, we can probably just replace the last lines of this function directly
Contributor
There was a problem hiding this comment.
It might just be better to just keep the old pattern and suppress the warnings - the reason being that this new implementation needs to iterate through all entry points for every group (because "select" has to search all entry points), whereas the prior approach is still a single pass
Assisted-by: OpenAI Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5231
Summary
SelectableGroupswithout using its deprecated dict interface.DeprecationWarningas an error while convertingSelectableGroups.Why
On Python 3.10 and 3.11,
importlib.metadata.entry_points()can returnSelectableGroups. Calling its dict-likevalues()emits aDeprecationWarning, which breaks users running with warnings as errors when importingopentelemetry.context.Testing
python3 -m pytest opentelemetry-api/tests/util/test__importlib_metadata.py- passedpython3 -W error -c 'import opentelemetry.context'- passed\n- Ran:python3 -W error -m pytest opentelemetry-api/tests/util/test__importlib_metadata.py- passed\n- Ran:python3 -m ruff check opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py opentelemetry-api/tests/util/test__importlib_metadata.py- passed\n- Ran:python3 -m py_compile opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py opentelemetry-api/tests/util/test__importlib_metadata.py- passed\n\n## Notes\n- Full tox/precommit not run locally becauseuvandtoxare not installed in this shell.\n