Skip to content

Commit ab57ac7

Browse files
jaracoclaude
andcommitted
gh-123976: Warn only on an incomplete provider
importlib_metadata now decides the warning by conformance to IDistribution rather than by class identity, so a provider that presents the whole interface draws no warning and the warning names what a class omits. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent ac1128a commit ab57ac7

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎Doc/library/importlib.metadata.rst‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -760,21 +760,21 @@ documented here supplies objects from the other hierarchy.
760760

761761
The backport settles most of this on the consumer's behalf, substituting its
762762
own class for each object it recognizes, such as a :class:`!PathDistribution`,
763-
a :class:`PackagePath`, or an :class:`email.message.Message`. It cannot do so
764-
for an arbitrary :class:`Distribution` subclass from a custom provider, having
765-
no way to reconstruct that subclass. Such an object is passed through
766-
unchanged, and the backport emits a :exc:`UserWarning` reporting the
767-
unrecognized subclass.
763+
a :class:`PackagePath`, or an :class:`email.message.Message`. It has no way to
764+
reconstruct an arbitrary :class:`Distribution` subclass from a custom
765+
provider, so it passes such an object through unchanged. That serves the
766+
consumer as long as the object presents the whole interface; where the class
767+
omits a member the interface requires, the backport emits a
768+
:exc:`UserWarning` naming what is missing.
768769

769-
A passed-through object still serves the consumer, provided it implements the
770-
whole interface rather than part of it. So, when writing a custom provider:
770+
So, when writing a custom provider:
771771

772772
* Supply objects that present the whole interface, not part of it. Deriving
773773
from :class:`Distribution`, as the example above does, achieves this: the
774774
base class builds the rest of the interface on
775-
:meth:`~Distribution.read_text` and :meth:`~Distribution.locate_file`. A
776-
provider that assembles its objects some other way supplies every member
777-
itself.
775+
:meth:`~Distribution.read_text` and :meth:`~Distribution.locate_file`, and
776+
such a provider draws no warning. A provider that assembles its objects
777+
some other way supplies every member itself.
778778
* Where the provider itself consumes metadata, and in the guidance offered to
779779
its users, rely on the object satisfying that interface rather than on its
780780
type. The backport publishes ``IDistribution``, ``IPackagePath``, and

0 commit comments

Comments
 (0)