File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -511,7 +511,7 @@ def _discover_resolvers():
511511 return filter (None , declared )
512512
513513 @property
514- def metadata (self ) -> _meta .PackageMetadata :
514+ def metadata (self ) -> _meta .PackageMetadata | None :
515515 """Return the parsed metadata for this Distribution.
516516
517517 The returned object will have keys that name the various bits of
@@ -521,18 +521,23 @@ def metadata(self) -> _meta.PackageMetadata:
521521 Custom providers may provide the METADATA file or override this
522522 property.
523523 """
524- # deferred for performance (python/cpython#109829)
525- from . import _adapters
526524
527- opt_text = (
525+ text = (
528526 self .read_text ('METADATA' )
529527 or self .read_text ('PKG-INFO' )
530528 # This last clause is here to support old egg-info files. Its
531529 # effect is to just end up using the PathDistribution's self._path
532530 # (which points to the egg-info file) attribute unchanged.
533531 or self .read_text ('' )
534532 )
535- text = cast (str , opt_text )
533+ return self ._assemble_message (text )
534+
535+ @staticmethod
536+ @pass_none
537+ def _assemble_message (text : str ) -> _meta .PackageMetadata :
538+ # deferred for performance (python/cpython#109829)
539+ from . import _adapters
540+
536541 return _adapters .Message (email .message_from_string (text ))
537542
538543 @property
You can’t perform that action at this time.
0 commit comments