-
Notifications
You must be signed in to change notification settings - Fork 2
Fix Union entry point discovery on Python <3.12
#84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NiklasRosenstein
merged 6 commits into
develop
from
copilot/fix-importlib-metadata-usage
May 22, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8d3459b
Initial plan
Copilot ac614f6
fix(core): support importlib.metadata.entry_points on Python <3.12
Copilot 56f9c4f
test(core): skip union entry point tests on Python 3.8 and add changelog
claude c21a505
refactor(core): drop pkg_resources fallback in favor of importlib.met…
claude 9258e18
chore: remove dead setuptools dependency and types-setuptools
claude 90887c3
test(core): import MonkeyPatch from the public pytest API
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [[entries]] | ||
| id = "67afd70b-b66e-4aeb-ab30-becf3f121681" | ||
| type = "fix" | ||
| description = "Fix `Union` entry point discovery by no longer passing the `group` keyword to `importlib.metadata.entry_points()`, drop the deprecated `pkg_resources` fallback (`importlib.metadata` is used on all supported Python versions), and remove the now-unused `setuptools` runtime dependency on Python <3.9" | ||
| author = "@NiklasRosenstein" | ||
| pr = "https://github.com/NiklasRosenstein/python-databind/pull/84" |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import typing as t | ||
|
|
||
| from pytest import MonkeyPatch | ||
|
|
||
| import databind.core.union as union_module | ||
|
|
||
|
|
||
| def test_iter_entry_points_uses_select_api_without_call_arguments(monkeypatch: MonkeyPatch) -> None: | ||
| result = [object(), object()] | ||
|
|
||
| class EntryPoints: | ||
| def __init__(self) -> None: | ||
| self.selected_group: str | None = None | ||
|
|
||
| def select(self, *, group: str) -> list[object]: | ||
| self.selected_group = group | ||
| return result | ||
|
|
||
| eps = EntryPoints() | ||
|
|
||
| def fake_entry_points(*args: object, **kwargs: object) -> object: | ||
| assert args == () | ||
| assert kwargs == {} | ||
| return eps | ||
|
|
||
| monkeypatch.setattr(union_module, "entry_points", fake_entry_points) | ||
|
|
||
| assert list(union_module.iter_entry_points("my.group")) == t.cast(t.Any, result) | ||
| assert eps.selected_group == "my.group" | ||
|
|
||
|
|
||
| def test_iter_entry_points_falls_back_to_mapping_result(monkeypatch: MonkeyPatch) -> None: | ||
| result = [object(), object()] | ||
|
|
||
| def fake_entry_points(*args: object, **kwargs: object) -> object: | ||
| assert args == () | ||
| assert kwargs == {} | ||
| return {"my.group": result} | ||
|
|
||
| monkeypatch.setattr(union_module, "entry_points", fake_entry_points) | ||
|
|
||
| assert list(union_module.iter_entry_points("my.group")) == t.cast(t.Any, result) | ||
| assert list(union_module.iter_entry_points("missing")) == [] | ||
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.