-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Expand documentation for importlib.metadata custom providers to include caveats regarding backports #123976
Comments
As I write that recommendation, I'm already uncomfortable with the recommendation. It's unclear what "when I think it has to mean it's available for import, because the provider can't tell if it will later be imported by a consumer. But that also means the provider might activate That also means that users of Also, "register with |
All of this has me re-thinking the strategy. Maybe instead of having two distinct class trees ( |
Triage: #123977 has been merged, ready to close this? |
Thanks, but no. The PR only did some minor refreshing of the docs. The core concern of this issue remains. |
Documentation
As
importlib_metadata
provides a backport ofimportlib.metadata
and asserts primacy when imported, for consumers of the API, it provides a consistent interface, except when a custom provider serves objects as imported fromimportlib.metadata
(not using the backport). For example:sys.meta_path
providingimportlib.metadata.Distribution
instances.importlib_metadata.distributions()
to return all distributions, including that of project A.Iterable[importlib_metadata.Distribution]
objects, their expectation is violated when theDistributionFinder
installed by project A emitsimportlib.metadata.Distribution
objects.python/importlib_metadata#486 captures this concern. python/importlib_metadata#505 promises to correct this concern by wrapping and transforming any objects from custom providers referencing
importlib.metadata
to instead use objects fromimportlib_metadata
.However, for
importlib.metadata.Distribution
objects, it's not possible to replace safely the objects of an arbitrary custom provider, so the proposed implementation emits a warning when such an object is encountered.Therefore, we'd like to add some documentation to the custom provider docs to advise custom providers on what to do to avoid their users encountering the warning. In particular:
Linked PRs
The text was updated successfully, but these errors were encountered: