@@ -543,7 +543,7 @@ def _assemble_message(text: str) -> _meta.PackageMetadata:
543543 @property
544544 def name (self ) -> str :
545545 """Return the 'Name' metadata for the distribution package."""
546- return self .metadata ['Name' ]
546+ return cast ( PackageMetadata , self .metadata ) ['Name' ]
547547
548548 @property
549549 def _normalized_name (self ):
@@ -553,7 +553,7 @@ def _normalized_name(self):
553553 @property
554554 def version (self ) -> str :
555555 """Return the 'Version' metadata for the distribution package."""
556- return self .metadata ['Version' ]
556+ return cast ( PackageMetadata , self .metadata ) ['Version' ]
557557
558558 @property
559559 def entry_points (self ) -> EntryPoints :
@@ -1050,7 +1050,7 @@ def distributions(**kwargs) -> Iterable[Distribution]:
10501050 return Distribution .discover (** kwargs )
10511051
10521052
1053- def metadata (distribution_name : str ) -> _meta .PackageMetadata :
1053+ def metadata (distribution_name : str ) -> _meta .PackageMetadata | None :
10541054 """Get the metadata for the named package.
10551055
10561056 :param distribution_name: The name of the distribution package to query.
@@ -1125,7 +1125,7 @@ def packages_distributions() -> Mapping[str, list[str]]:
11251125 pkg_to_dist = collections .defaultdict (list )
11261126 for dist in distributions ():
11271127 for pkg in _top_level_declared (dist ) or _top_level_inferred (dist ):
1128- pkg_to_dist [pkg ].append (dist .metadata ['Name' ])
1128+ pkg_to_dist [pkg ].append (cast ( PackageMetadata , dist .metadata ) ['Name' ])
11291129 return dict (pkg_to_dist )
11301130
11311131
0 commit comments