massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / importlib / metadata.pyi
1 import abc
2 import pathlib
3 import sys
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
11
12 if sys.version_info >= (3, 10):
13     def packages_distributions() -> Mapping[str, list[str]]: ...
14
15 if sys.version_info >= (3, 8):
16     class PackageNotFoundError(ModuleNotFoundError): ...
17     class _EntryPointBase(NamedTuple):
18         name: str
19         value: str
20         group: str
21     class EntryPoint(_EntryPointBase):
22         def load(self) -> Any: ...  # Callable[[], Any] or an importable module
23         @property
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:
30         hash: FileHash | None
31         size: int | None
32         dist: Distribution
33     class FileHash:
34         mode: str
35         value: str
36         def __init__(self, spec: str) -> None: ...
37     class Distribution:
38         @abc.abstractmethod
39         def read_text(self, filename: str) -> str | None: ...
40         @abc.abstractmethod
41         def locate_file(self, path: StrPath) -> PathLike[str]: ...
42         @classmethod
43         def from_name(cls, name: str) -> Distribution: ...
44         @overload
45         @classmethod
46         def discover(cls, *, context: DistributionFinder.Context) -> Iterable[Distribution]: ...
47         @overload
48         @classmethod
49         def discover(
50             cls, *, context: None = ..., name: str | None = ..., path: list[str] = ..., **kwargs: Any
51         ) -> Iterable[Distribution]: ...
52         @staticmethod
53         def at(path: StrPath) -> PathDistribution: ...
54         @property
55         def metadata(self) -> Message: ...
56         @property
57         def version(self) -> str: ...
58         @property
59         def entry_points(self) -> list[EntryPoint]: ...
60         @property
61         def files(self) -> list[PackagePath] | None: ...
62         @property
63         def requires(self) -> list[str] | None: ...
64     class DistributionFinder(MetaPathFinder):
65         class Context:
66             name: str | None
67             def __init__(self, *, name: str | None = ..., path: list[str] = ..., **kwargs: Any) -> None: ...
68             @property
69             def path(self) -> list[str]: ...
70         @abc.abstractmethod
71         def find_distributions(self, context: DistributionFinder.Context = ...) -> Iterable[Distribution]: ...
72     class MetadataPathFinder(DistributionFinder):
73         @classmethod
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: ...
80     @overload
81     def distributions(*, context: DistributionFinder.Context) -> Iterable[Distribution]: ...
82     @overload
83     def distributions(
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: ...