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():
511
511
return filter (None , declared )
512
512
513
513
@property
514
- def metadata (self ) -> _meta .PackageMetadata :
514
+ def metadata (self ) -> _meta .PackageMetadata | None :
515
515
"""Return the parsed metadata for this Distribution.
516
516
517
517
The returned object will have keys that name the various bits of
@@ -521,18 +521,23 @@ def metadata(self) -> _meta.PackageMetadata:
521
521
Custom providers may provide the METADATA file or override this
522
522
property.
523
523
"""
524
- # deferred for performance (python/cpython#109829)
525
- from . import _adapters
526
524
527
- opt_text = (
525
+ text = (
528
526
self .read_text ('METADATA' )
529
527
or self .read_text ('PKG-INFO' )
530
528
# This last clause is here to support old egg-info files. Its
531
529
# effect is to just end up using the PathDistribution's self._path
532
530
# (which points to the egg-info file) attribute unchanged.
533
531
or self .read_text ('' )
534
532
)
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
+
536
541
return _adapters .Message (email .message_from_string (text ))
537
542
538
543
@property
You can’t perform that action at this time.
0 commit comments