mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Fix some pkg_resources variable types. (#3919)
Allow passing proper metadata to Distribution.from_location() and Distribution.from_filename(). Correct the order of arguments for the importer functions. Note that some functions accept any iterables, not just sized ones. Correct the type of the VersionConflict classes' context.
This commit is contained in:
16
third_party/3/pkg_resources/__init__.pyi
vendored
16
third_party/3/pkg_resources/__init__.pyi
vendored
@@ -12,7 +12,7 @@ _InstallerType = Callable[[Requirement], Optional[Distribution]]
|
||||
_EPDistType = Union[Distribution, Requirement, str]
|
||||
_MetadataType = Optional[IResourceProvider]
|
||||
_PkgReqType = Union[str, Requirement]
|
||||
_DistFinderType = Callable[[str, _Importer, bool], Generator[Distribution, None, None]]
|
||||
_DistFinderType = Callable[[_Importer, str, bool], Generator[Distribution, None, None]]
|
||||
_NSHandlerType = Callable[[_Importer, str, str, types.ModuleType], str]
|
||||
|
||||
def declare_namespace(name: str) -> None: ...
|
||||
@@ -29,7 +29,7 @@ class WorkingSet:
|
||||
def __iter__(self) -> Generator[Distribution, None, None]: ...
|
||||
def find(self, req: Requirement) -> Optional[Distribution]: ...
|
||||
def resolve(
|
||||
self, requirements: Sequence[Requirement], env: Optional[Environment] = ..., installer: Optional[_InstallerType] = ...
|
||||
self, requirements: Iterable[Requirement], env: Optional[Environment] = ..., installer: Optional[_InstallerType] = ...
|
||||
) -> List[Distribution]: ...
|
||||
def add(self, dist: Distribution, entry: Optional[str] = ..., insert: bool = ..., replace: bool = ...) -> None: ...
|
||||
def subscribe(self, callback: Callable[[Distribution], None]) -> None: ...
|
||||
@@ -133,7 +133,7 @@ class Distribution(IResourceProvider, IMetadataProvider):
|
||||
def __init__(
|
||||
self,
|
||||
location: Optional[str] = ...,
|
||||
metadata: Optional[str] = ...,
|
||||
metadata: _MetadataType = ...,
|
||||
project_name: Optional[str] = ...,
|
||||
version: Optional[str] = ...,
|
||||
py_version: str = ...,
|
||||
@@ -142,10 +142,10 @@ class Distribution(IResourceProvider, IMetadataProvider):
|
||||
) -> None: ...
|
||||
@classmethod
|
||||
def from_location(
|
||||
cls, location: str, basename: str, metadata: Optional[str] = ..., **kw: Union[str, None, int]
|
||||
cls, location: str, basename: str, metadata: _MetadataType = ..., **kw: Union[str, None, int]
|
||||
) -> Distribution: ...
|
||||
@classmethod
|
||||
def from_filename(cls, filename: str, metadata: Optional[str] = ..., **kw: Union[str, None, int]) -> Distribution: ...
|
||||
def from_filename(cls, filename: str, metadata: _MetadataType = ..., **kw: Union[str, None, int]) -> Distribution: ...
|
||||
def activate(self, path: Optional[List[str]] = ...) -> None: ...
|
||||
def as_requirement(self) -> Requirement: ...
|
||||
def requires(self, extras: Tuple[str, ...] = ...) -> List[Requirement]: ...
|
||||
@@ -183,7 +183,7 @@ class IResourceManager:
|
||||
def resource_filename(self, package_or_requirement: _PkgReqType, resource_name: str) -> str: ...
|
||||
def set_extraction_path(self, path: str) -> None: ...
|
||||
def cleanup_resources(self, force: bool = ...) -> List[str]: ...
|
||||
def get_cache_path(self, archive_name: str, names: Tuple[str, ...] = ...) -> str: ...
|
||||
def get_cache_path(self, archive_name: str, names: Iterable[str] = ...) -> str: ...
|
||||
def extraction_error(self) -> None: ...
|
||||
def postprocess(self, tempname: str, filename: str) -> None: ...
|
||||
|
||||
@@ -209,11 +209,11 @@ class VersionConflict(ResolutionError):
|
||||
@property
|
||||
def req(self) -> Any: ...
|
||||
def report(self) -> str: ...
|
||||
def with_context(self, required_by: Dict[str, Any]) -> VersionConflict: ...
|
||||
def with_context(self, required_by: Set[Union[Distribution, str]]) -> VersionConflict: ...
|
||||
|
||||
class ContextualVersionConflict(VersionConflict):
|
||||
@property
|
||||
def required_by(self) -> Set[Any]: ...
|
||||
def required_by(self) -> Set[Union[Distribution, str]]: ...
|
||||
|
||||
class UnknownExtra(ResolutionError): ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user