|
1 | 1 | import abc |
2 | 2 | import pathlib |
3 | 3 | import sys |
4 | | -from _typeshed import StrPath |
| 4 | +from _typeshed import Self, StrPath |
5 | 5 | from collections.abc import Mapping |
6 | 6 | from email.message import Message |
7 | 7 | from importlib.abc import MetaPathFinder |
@@ -61,7 +61,56 @@ class EntryPoint(_EntryPointBase): |
61 | 61 | def attr(self) -> str: ... |
62 | 62 | if sys.version_info >= (3, 10): |
63 | 63 | dist: ClassVar[Distribution | None] |
64 | | - def matches(self, **params: Any) -> bool: ... # undocumented |
| 64 | + def matches( |
| 65 | + self, |
| 66 | + *, |
| 67 | + name: str = ..., |
| 68 | + value: str = ..., |
| 69 | + group: str = ..., |
| 70 | + module: str = ..., |
| 71 | + attr: str = ..., |
| 72 | + extras: list[str] = ..., |
| 73 | + ) -> bool: ... # undocumented |
| 74 | + |
| 75 | +if sys.version_info >= (3, 10): |
| 76 | + class EntryPoints(list[EntryPoint]): # use as list is deprecated since 3.10 |
| 77 | + # int argument is deprecated since 3.10 |
| 78 | + def __getitem__(self, item: int | str) -> EntryPoint: ... # type: ignore[override] |
| 79 | + def select( |
| 80 | + self, |
| 81 | + *, |
| 82 | + name: str = ..., |
| 83 | + value: str = ..., |
| 84 | + group: str = ..., |
| 85 | + module: str = ..., |
| 86 | + attr: str = ..., |
| 87 | + extras: list[str] = ..., |
| 88 | + ) -> EntryPoints: ... |
| 89 | + @property |
| 90 | + def names(self) -> set[str]: ... |
| 91 | + @property |
| 92 | + def groups(self) -> set[str]: ... |
| 93 | + |
| 94 | + class SelectableGroups(dict[str, EntryPoints]): # use as dict is deprecated since 3.10 |
| 95 | + @classmethod |
| 96 | + def load(cls: type[Self], eps: Iterable[EntryPoint]) -> Self: ... |
| 97 | + @property |
| 98 | + def groups(self) -> set[str]: ... |
| 99 | + @property |
| 100 | + def names(self) -> set[str]: ... |
| 101 | + @overload |
| 102 | + def select(self: Self) -> Self: ... # type: ignore[misc] |
| 103 | + @overload |
| 104 | + def select( |
| 105 | + self, |
| 106 | + *, |
| 107 | + name: str = ..., |
| 108 | + value: str = ..., |
| 109 | + group: str = ..., |
| 110 | + module: str = ..., |
| 111 | + attr: str = ..., |
| 112 | + extras: list[str] = ..., |
| 113 | + ) -> EntryPoints: ... |
65 | 114 |
|
66 | 115 | class PackagePath(pathlib.PurePosixPath): |
67 | 116 | def read_text(self, encoding: str = ...) -> str: ... |
@@ -94,13 +143,21 @@ class Distribution: |
94 | 143 | ) -> Iterable[Distribution]: ... |
95 | 144 | @staticmethod |
96 | 145 | def at(path: StrPath) -> PathDistribution: ... |
97 | | - @property |
98 | | - def metadata(self) -> Message: ... |
| 146 | + |
| 147 | + if sys.version_info >= (3, 10): |
| 148 | + @property |
| 149 | + def metadata(self) -> PackageMetadata: ... |
| 150 | + @property |
| 151 | + def entry_points(self) -> EntryPoints: ... |
| 152 | + else: |
| 153 | + @property |
| 154 | + def metadata(self) -> Message: ... |
| 155 | + @property |
| 156 | + def entry_points(self) -> list[EntryPoint]: ... |
| 157 | + |
99 | 158 | @property |
100 | 159 | def version(self) -> str: ... |
101 | 160 | @property |
102 | | - def entry_points(self) -> list[EntryPoint]: ... |
103 | | - @property |
104 | 161 | def files(self) -> list[PackagePath] | None: ... |
105 | 162 | @property |
106 | 163 | def requires(self) -> list[str] | None: ... |
@@ -137,8 +194,20 @@ def distributions(*, context: DistributionFinder.Context) -> Iterable[Distributi |
137 | 194 | def distributions( |
138 | 195 | *, context: None = ..., name: str | None = ..., path: list[str] = ..., **kwargs: Any |
139 | 196 | ) -> Iterable[Distribution]: ... |
140 | | -def metadata(distribution_name: str) -> Message: ... |
| 197 | + |
| 198 | +if sys.version_info >= (3, 10): |
| 199 | + def metadata(distribution_name: str) -> PackageMetadata: ... |
| 200 | + @overload |
| 201 | + def entry_points() -> SelectableGroups: ... # type: ignore[misc] |
| 202 | + @overload |
| 203 | + def entry_points( |
| 204 | + *, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ... |
| 205 | + ) -> EntryPoints: ... |
| 206 | + |
| 207 | +else: |
| 208 | + def metadata(distribution_name: str) -> Message: ... |
| 209 | + def entry_points() -> dict[str, list[EntryPoint]]: ... |
| 210 | + |
141 | 211 | def version(distribution_name: str) -> str: ... |
142 | | -def entry_points() -> dict[str, tuple[EntryPoint, ...]]: ... |
143 | 212 | def files(distribution_name: str) -> list[PackagePath] | None: ... |
144 | 213 | def requires(distribution_name: str) -> list[str] | None: ... |
0 commit comments