@@ -9,108 +9,136 @@ from os import PathLike
99from pathlib import Path
1010from typing import Any , ClassVar , Iterable , NamedTuple , Pattern , overload
1111
12+ if sys .version_info >= (3 , 10 ):
13+ __all__ = [
14+ "Distribution" ,
15+ "DistributionFinder" ,
16+ "PackageMetadata" ,
17+ "PackageNotFoundError" ,
18+ "distribution" ,
19+ "distributions" ,
20+ "entry_points" ,
21+ "files" ,
22+ "metadata" ,
23+ "packages_distributions" ,
24+ "requires" ,
25+ "version" ,
26+ ]
27+ else :
28+ __all__ = [
29+ "Distribution" ,
30+ "DistributionFinder" ,
31+ "PackageNotFoundError" ,
32+ "distribution" ,
33+ "distributions" ,
34+ "entry_points" ,
35+ "files" ,
36+ "metadata" ,
37+ "requires" ,
38+ "version" ,
39+ ]
40+
1241if sys .version_info >= (3 , 10 ):
1342 from importlib .metadata ._meta import PackageMetadata as PackageMetadata
1443 def packages_distributions () -> Mapping [str , list [str ]]: ...
1544
16- if sys .version_info >= (3 , 8 ):
17- class PackageNotFoundError (ModuleNotFoundError ): ...
45+ class PackageNotFoundError (ModuleNotFoundError ): ...
1846
19- class _EntryPointBase (NamedTuple ):
20- name : str
21- value : str
22- group : str
47+ class _EntryPointBase (NamedTuple ):
48+ name : str
49+ value : str
50+ group : str
2351
24- class EntryPoint (_EntryPointBase ):
25- pattern : ClassVar [Pattern [str ]]
26- def load (self ) -> Any : ... # Callable[[], Any] or an importable module
52+ class EntryPoint (_EntryPointBase ):
53+ pattern : ClassVar [Pattern [str ]]
54+ def load (self ) -> Any : ... # Callable[[], Any] or an importable module
55+ @property
56+ def extras (self ) -> list [str ]: ...
57+ if sys .version_info >= (3 , 9 ):
2758 @property
28- def extras (self ) -> list [str ]: ...
29- if sys .version_info >= (3 , 9 ):
30- @property
31- def module (self ) -> str : ...
32- @property
33- def attr (self ) -> str : ...
34- if sys .version_info >= (3 , 10 ):
35- dist : ClassVar [Distribution | None ]
36- def matches (self , ** params : Any ) -> bool : ... # undocumented
59+ def module (self ) -> str : ...
60+ @property
61+ def attr (self ) -> str : ...
62+ if sys .version_info >= (3 , 10 ):
63+ dist : ClassVar [Distribution | None ]
64+ def matches (self , ** params : Any ) -> bool : ... # undocumented
3765
38- class PackagePath (pathlib .PurePosixPath ):
39- def read_text (self , encoding : str = ...) -> str : ...
40- def read_binary (self ) -> bytes : ...
41- def locate (self ) -> PathLike [str ]: ...
42- # The following attributes are not defined on PackagePath, but are dynamically added by Distribution.files:
43- hash : FileHash | None
44- size : int | None
45- dist : Distribution
66+ class PackagePath (pathlib .PurePosixPath ):
67+ def read_text (self , encoding : str = ...) -> str : ...
68+ def read_binary (self ) -> bytes : ...
69+ def locate (self ) -> PathLike [str ]: ...
70+ # The following attributes are not defined on PackagePath, but are dynamically added by Distribution.files:
71+ hash : FileHash | None
72+ size : int | None
73+ dist : Distribution
4674
47- class FileHash :
48- mode : str
49- value : str
50- def __init__ (self , spec : str ) -> None : ...
75+ class FileHash :
76+ mode : str
77+ value : str
78+ def __init__ (self , spec : str ) -> None : ...
5179
52- class Distribution :
53- @abc .abstractmethod
54- def read_text (self , filename : str ) -> str | None : ...
55- @abc .abstractmethod
56- def locate_file (self , path : StrPath ) -> PathLike [str ]: ...
57- @classmethod
58- def from_name (cls , name : str ) -> Distribution : ...
59- @overload
60- @classmethod
61- def discover (cls , * , context : DistributionFinder .Context ) -> Iterable [Distribution ]: ...
62- @overload
63- @classmethod
64- def discover (
65- cls , * , context : None = ..., name : str | None = ..., path : list [str ] = ..., ** kwargs : Any
66- ) -> Iterable [Distribution ]: ...
67- @staticmethod
68- def at (path : StrPath ) -> PathDistribution : ...
69- @property
70- def metadata (self ) -> Message : ...
71- @property
72- def version (self ) -> str : ...
73- @property
74- def entry_points (self ) -> list [EntryPoint ]: ...
75- @property
76- def files (self ) -> list [PackagePath ] | None : ...
80+ class Distribution :
81+ @abc .abstractmethod
82+ def read_text (self , filename : str ) -> str | None : ...
83+ @abc .abstractmethod
84+ def locate_file (self , path : StrPath ) -> PathLike [str ]: ...
85+ @classmethod
86+ def from_name (cls , name : str ) -> Distribution : ...
87+ @overload
88+ @classmethod
89+ def discover (cls , * , context : DistributionFinder .Context ) -> Iterable [Distribution ]: ...
90+ @overload
91+ @classmethod
92+ def discover (
93+ cls , * , context : None = ..., name : str | None = ..., path : list [str ] = ..., ** kwargs : Any
94+ ) -> Iterable [Distribution ]: ...
95+ @staticmethod
96+ def at (path : StrPath ) -> PathDistribution : ...
97+ @property
98+ def metadata (self ) -> Message : ...
99+ @property
100+ def version (self ) -> str : ...
101+ @property
102+ def entry_points (self ) -> list [EntryPoint ]: ...
103+ @property
104+ def files (self ) -> list [PackagePath ] | None : ...
105+ @property
106+ def requires (self ) -> list [str ] | None : ...
107+ if sys .version_info >= (3 , 10 ):
77108 @property
78- def requires (self ) -> list [str ] | None : ...
79- if sys .version_info >= (3 , 10 ):
80- @property
81- def name (self ) -> str : ...
109+ def name (self ) -> str : ...
82110
83- class DistributionFinder (MetaPathFinder ):
84- class Context :
85- name : str | None
86- def __init__ (self , * , name : str | None = ..., path : list [str ] = ..., ** kwargs : Any ) -> None : ...
87- @property
88- def path (self ) -> list [str ]: ...
111+ class DistributionFinder (MetaPathFinder ):
112+ class Context :
113+ name : str | None
114+ def __init__ (self , * , name : str | None = ..., path : list [str ] = ..., ** kwargs : Any ) -> None : ...
115+ @property
116+ def path (self ) -> list [str ]: ...
89117
90- @abc .abstractmethod
91- def find_distributions (self , context : DistributionFinder .Context = ...) -> Iterable [Distribution ]: ...
118+ @abc .abstractmethod
119+ def find_distributions (self , context : DistributionFinder .Context = ...) -> Iterable [Distribution ]: ...
92120
93- class MetadataPathFinder (DistributionFinder ):
94- @classmethod
95- def find_distributions (cls , context : DistributionFinder .Context = ...) -> Iterable [PathDistribution ]: ...
96- if sys .version_info >= (3 , 10 ):
97- # Yes, this is an instance method that has argumend named "cls"
98- def invalidate_caches (cls ) -> None : ... # type: ignore
121+ class MetadataPathFinder (DistributionFinder ):
122+ @classmethod
123+ def find_distributions (cls , context : DistributionFinder .Context = ...) -> Iterable [PathDistribution ]: ...
124+ if sys .version_info >= (3 , 10 ):
125+ # Yes, this is an instance method that has argumend named "cls"
126+ def invalidate_caches (cls ) -> None : ... # type: ignore
99127
100- class PathDistribution (Distribution ):
101- def __init__ (self , path : Path ) -> None : ...
102- def read_text (self , filename : StrPath ) -> str : ...
103- def locate_file (self , path : StrPath ) -> PathLike [str ]: ...
128+ class PathDistribution (Distribution ):
129+ def __init__ (self , path : Path ) -> None : ...
130+ def read_text (self , filename : StrPath ) -> str : ...
131+ def locate_file (self , path : StrPath ) -> PathLike [str ]: ...
104132
105- def distribution (distribution_name : str ) -> Distribution : ...
106- @overload
107- def distributions (* , context : DistributionFinder .Context ) -> Iterable [Distribution ]: ...
108- @overload
109- def distributions (
110- * , context : None = ..., name : str | None = ..., path : list [str ] = ..., ** kwargs : Any
111- ) -> Iterable [Distribution ]: ...
112- def metadata (distribution_name : str ) -> Message : ...
113- def version (distribution_name : str ) -> str : ...
114- def entry_points () -> dict [str , tuple [EntryPoint , ...]]: ...
115- def files (distribution_name : str ) -> list [PackagePath ] | None : ...
116- def requires (distribution_name : str ) -> list [str ] | None : ...
133+ def distribution (distribution_name : str ) -> Distribution : ...
134+ @overload
135+ def distributions (* , context : DistributionFinder .Context ) -> Iterable [Distribution ]: ...
136+ @overload
137+ def distributions (
138+ * , context : None = ..., name : str | None = ..., path : list [str ] = ..., ** kwargs : Any
139+ ) -> Iterable [Distribution ]: ...
140+ def metadata (distribution_name : str ) -> Message : ...
141+ def version (distribution_name : str ) -> str : ...
142+ def entry_points () -> dict [str , tuple [EntryPoint , ...]]: ...
143+ def files (distribution_name : str ) -> list [PackagePath ] | None : ...
144+ def requires (distribution_name : str ) -> list [str ] | None : ...
0 commit comments