14
14
import posixpath
15
15
import collections
16
16
17
+ from . import _adapters , _meta
17
18
from ._collections import FreezableDefaultDict , Pair
18
19
from ._functools import method_cache
19
20
from ._itertools import unique_everseen
22
23
from importlib import import_module
23
24
from importlib .abc import MetaPathFinder
24
25
from itertools import starmap
25
- from typing import Any , List , Mapping , Optional , Protocol , TypeVar , Union
26
+ from typing import List , Mapping , Optional , Union
26
27
27
28
28
29
__all__ = [
@@ -385,25 +386,6 @@ def __repr__(self):
385
386
return '<FileHash mode: {} value: {}>' .format (self .mode , self .value )
386
387
387
388
388
- _T = TypeVar ("_T" )
389
-
390
-
391
- class PackageMetadata (Protocol ):
392
- def __len__ (self ) -> int :
393
- ... # pragma: no cover
394
-
395
- def __contains__ (self , item : str ) -> bool :
396
- ... # pragma: no cover
397
-
398
- def __getitem__ (self , key : str ) -> str :
399
- ... # pragma: no cover
400
-
401
- def get_all (self , name : str , failobj : _T = ...) -> Union [List [Any ], _T ]:
402
- """
403
- Return all values associated with a possibly multi-valued key.
404
- """
405
-
406
-
407
389
class Distribution :
408
390
"""A Python distribution package."""
409
391
@@ -488,7 +470,7 @@ def _local(cls, root='.'):
488
470
return PathDistribution (zipfile .Path (meta .build_as_zip (builder )))
489
471
490
472
@property
491
- def metadata (self ) -> PackageMetadata :
473
+ def metadata (self ) -> _meta . PackageMetadata :
492
474
"""Return the parsed metadata for this Distribution.
493
475
494
476
The returned object will have keys that name the various bits of
@@ -502,7 +484,7 @@ def metadata(self) -> PackageMetadata:
502
484
# (which points to the egg-info file) attribute unchanged.
503
485
or self .read_text ('' )
504
486
)
505
- return email .message_from_string (text )
487
+ return _adapters . Message ( email .message_from_string (text ) )
506
488
507
489
@property
508
490
def name (self ):
@@ -829,7 +811,7 @@ def distributions(**kwargs):
829
811
return Distribution .discover (** kwargs )
830
812
831
813
832
- def metadata (distribution_name ) -> PackageMetadata :
814
+ def metadata (distribution_name ) -> _meta . PackageMetadata :
833
815
"""Get the metadata for the named package.
834
816
835
817
:param distribution_name: The name of the distribution package to query.
0 commit comments