@@ -5,19 +5,20 @@ from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
5
5
from io import BytesIO
6
6
from pkgutil import get_importer as get_importer
7
7
from re import Pattern
8
- from typing import IO , Any , ClassVar , Final , Literal , Protocol , TypeVar , overload , type_check_only
8
+ from typing import IO , Any , ClassVar , Final , Literal , NoReturn , Protocol , TypeVar , overload , type_check_only
9
9
from typing_extensions import Self , TypeAlias
10
10
from zipfile import ZipInfo
11
11
12
12
from ._vendored_packaging import requirements as packaging_requirements , version as packaging_version
13
13
14
14
_T = TypeVar ("_T" )
15
15
_D = TypeVar ("_D" , bound = Distribution )
16
- _NestedStr : TypeAlias = str | Iterable [str | Iterable [Any ]]
16
+ _NestedStr : TypeAlias = str | Iterable [str | Iterable [_NestedStr ]]
17
17
_InstallerType : TypeAlias = Callable [[Requirement ], Distribution | None ]
18
18
_EPDistType : TypeAlias = Distribution | Requirement | str
19
19
_MetadataType : TypeAlias = IResourceProvider | None
20
20
_PkgReqType : TypeAlias = str | Requirement
21
+ _ResolvedEntryPoint : TypeAlias = Any # Can be any attribute in the module
21
22
_ModuleLike : TypeAlias = object | types .ModuleType # Any object that optionally has __loader__ or __file__, usually a module
22
23
_ProviderFactoryType : TypeAlias = Callable [[_ModuleLike ], IResourceProvider ]
23
24
_DistFinderType : TypeAlias = Callable [[_T , str , bool ], Iterable [Distribution ]]
@@ -158,7 +159,7 @@ class Environment:
158
159
def obtain (self , requirement : Requirement , installer : Callable [[Requirement ], _T ]) -> _T : ...
159
160
def __iter__ (self ) -> Iterator [str ]: ...
160
161
def __iadd__ (self , other : Distribution | Environment ) -> Self : ...
161
- def __add__ (self , other : Distribution | Environment ) -> Environment : ...
162
+ def __add__ (self , other : Distribution | Environment ) -> Self : ...
162
163
163
164
AvailableDistributions = Environment
164
165
@@ -178,7 +179,7 @@ class Requirement(packaging_requirements.Requirement):
178
179
@staticmethod
179
180
def parse (s : str | Iterable [str ]) -> Requirement : ...
180
181
181
- def load_entry_point (dist : _EPDistType , group : str , name : str ) -> Any : ...
182
+ def load_entry_point (dist : _EPDistType , group : str , name : str ) -> _ResolvedEntryPoint : ...
182
183
@overload
183
184
def get_entry_map (dist : _EPDistType , group : None = None ) -> dict [str , dict [str , EntryPoint ]]: ...
184
185
@overload
@@ -200,11 +201,13 @@ class EntryPoint:
200
201
extras : tuple [str , ...] = (),
201
202
dist : Distribution | None = None ,
202
203
) -> None : ...
203
- def load (self , require : bool = True , env : Environment | None = ..., installer : _InstallerType | None = ...) -> Any : ...
204
- def resolve (self ) -> Any : ...
204
+ def load (
205
+ self , require : bool = True , env : Environment | None = ..., installer : _InstallerType | None = ...
206
+ ) -> _ResolvedEntryPoint : ...
207
+ def resolve (self ) -> _ResolvedEntryPoint : ...
205
208
def require (self , env : Environment | None = None , installer : _InstallerType | None = None ) -> None : ...
206
209
@classmethod
207
- def parse (cls , src : str , dist : Distribution | None = None ) -> EntryPoint : ...
210
+ def parse (cls , src : str , dist : Distribution | None = None ) -> Self : ...
208
211
@classmethod
209
212
def parse_group (cls , group : str , lines : str | Sequence [str ], dist : Distribution | None = None ) -> dict [str , EntryPoint ]: ...
210
213
@classmethod
@@ -235,7 +238,7 @@ class ResourceManager:
235
238
def resource_stream (self , package_or_requirement : _PkgReqType , resource_name : str ) -> IO [bytes ]: ...
236
239
def resource_string (self , package_or_requirement : _PkgReqType , resource_name : str ) -> bytes : ...
237
240
def resource_listdir (self , package_or_requirement : _PkgReqType , resource_name : str ) -> list [str ]: ...
238
- def extraction_error (self ) -> None : ...
241
+ def extraction_error (self ) -> NoReturn : ...
239
242
def get_cache_path (self , archive_name : str , names : Iterable [str ] = ()) -> str : ...
240
243
def postprocess (self , tempname : str , filename : str ) -> None : ...
241
244
def set_extraction_path (self , path : str ) -> None : ...
@@ -267,25 +270,28 @@ class IMetadataProvider(Protocol):
267
270
class ResolutionError (Exception ): ...
268
271
269
272
class DistributionNotFound (ResolutionError ):
273
+ def __init__ (self , req : Requirement , requirers : set [str ] | None , / , * args : object ) -> None : ...
270
274
@property
271
275
def req (self ) -> Requirement : ...
272
276
@property
273
- def requirers (self ) -> set [str ]: ...
277
+ def requirers (self ) -> set [str ] | None : ...
274
278
@property
275
279
def requirers_str (self ) -> str : ...
276
280
def report (self ) -> str : ...
277
281
278
282
class VersionConflict (ResolutionError ):
283
+ def __init__ (self , dist : Distribution , req : Requirement , / , * args : object ) -> None : ...
279
284
@property
280
- def dist (self ) -> Any : ...
285
+ def dist (self ) -> Distribution : ...
281
286
@property
282
- def req (self ) -> Any : ...
287
+ def req (self ) -> Requirement : ...
283
288
def report (self ) -> str : ...
284
- def with_context (self , required_by : set [Distribution | str ]) -> VersionConflict : ...
289
+ def with_context (self , required_by : set [str ]) -> Self | ContextualVersionConflict : ...
285
290
286
291
class ContextualVersionConflict (VersionConflict ):
292
+ def __init__ (self , dist : Distribution , req : Requirement , required_by : set [str ], / , * args : object ) -> None : ...
287
293
@property
288
- def required_by (self ) -> set [Distribution | str ]: ...
294
+ def required_by (self ) -> set [str ]: ...
289
295
290
296
class UnknownExtra (ResolutionError ): ...
291
297
@@ -372,7 +378,7 @@ class Distribution(NullProvider):
372
378
@classmethod
373
379
def from_filename (cls , filename : str , metadata : _MetadataType = None , ** kw : str | None | int ) -> Distribution : ...
374
380
def as_requirement (self ) -> Requirement : ...
375
- def load_entry_point (self , group : str , name : str ) -> Any : ...
381
+ def load_entry_point (self , group : str , name : str ) -> _ResolvedEntryPoint : ...
376
382
@overload
377
383
def get_entry_map (self , group : None = None ) -> dict [str , dict [str , EntryPoint ]]: ...
378
384
@overload
0 commit comments