4 from _typeshed import StrPath
5 from collections.abc import Mapping
6 from email.message import Message
7 from importlib.abc import MetaPathFinder
8 from os import PathLike
9 from pathlib import Path
10 from typing import Any, Iterable, NamedTuple, Tuple, overload
12 if sys.version_info >= (3, 10):
13 def packages_distributions() -> Mapping[str, list[str]]: ...
15 if sys.version_info >= (3, 8):
16 class PackageNotFoundError(ModuleNotFoundError): ...
17 class _EntryPointBase(NamedTuple):
21 class EntryPoint(_EntryPointBase):
22 def load(self) -> Any: ... # Callable[[], Any] or an importable module
24 def extras(self) -> list[str]: ...
25 class PackagePath(pathlib.PurePosixPath):
26 def read_text(self, encoding: str = ...) -> str: ...
27 def read_binary(self) -> bytes: ...
28 def locate(self) -> PathLike[str]: ...
29 # The following attributes are not defined on PackagePath, but are dynamically added by Distribution.files:
36 def __init__(self, spec: str) -> None: ...
39 def read_text(self, filename: str) -> str | None: ...
41 def locate_file(self, path: StrPath) -> PathLike[str]: ...
43 def from_name(cls, name: str) -> Distribution: ...
46 def discover(cls, *, context: DistributionFinder.Context) -> Iterable[Distribution]: ...
50 cls, *, context: None = ..., name: str | None = ..., path: list[str] = ..., **kwargs: Any
51 ) -> Iterable[Distribution]: ...
53 def at(path: StrPath) -> PathDistribution: ...
55 def metadata(self) -> Message: ...
57 def version(self) -> str: ...
59 def entry_points(self) -> list[EntryPoint]: ...
61 def files(self) -> list[PackagePath] | None: ...
63 def requires(self) -> list[str] | None: ...
64 class DistributionFinder(MetaPathFinder):
67 def __init__(self, *, name: str | None = ..., path: list[str] = ..., **kwargs: Any) -> None: ...
69 def path(self) -> list[str]: ...
71 def find_distributions(self, context: DistributionFinder.Context = ...) -> Iterable[Distribution]: ...
72 class MetadataPathFinder(DistributionFinder):
74 def find_distributions(cls, context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ...
75 class PathDistribution(Distribution):
76 def __init__(self, path: Path) -> None: ...
77 def read_text(self, filename: StrPath) -> str: ...
78 def locate_file(self, path: StrPath) -> PathLike[str]: ...
79 def distribution(distribution_name: str) -> Distribution: ...
81 def distributions(*, context: DistributionFinder.Context) -> Iterable[Distribution]: ...
84 *, context: None = ..., name: str | None = ..., path: list[str] = ..., **kwargs: Any
85 ) -> Iterable[Distribution]: ...
86 def metadata(distribution_name: str) -> Message: ...
87 def version(distribution_name: str) -> str: ...
88 def entry_points() -> dict[str, Tuple[EntryPoint, ...]]: ...
89 def files(distribution_name: str) -> list[PackagePath] | None: ...
90 def requires(distribution_name: str) -> list[str] | None: ...