Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 77 additions & 8 deletions stdlib/importlib/metadata/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc
import pathlib
import sys
from _typeshed import StrPath
from _typeshed import Self, StrPath
from collections.abc import Mapping
from email.message import Message
from importlib.abc import MetaPathFinder
Expand Down Expand Up @@ -61,7 +61,56 @@ class EntryPoint(_EntryPointBase):
def attr(self) -> str: ...
if sys.version_info >= (3, 10):
dist: ClassVar[Distribution | None]
def matches(self, **params: Any) -> bool: ... # undocumented
def matches(
self,
*,
name: str = ...,
value: str = ...,
group: str = ...,
module: str = ...,
attr: str = ...,
extras: list[str] = ...,
) -> bool: ... # undocumented

if sys.version_info >= (3, 10):
class EntryPoints(list[EntryPoint]): # use as list is deprecated since 3.10
# int argument is deprecated since 3.10
def __getitem__(self, item: int | str) -> EntryPoint: ... # type: ignore[override]
def select(
self,
*,
name: str = ...,
value: str = ...,
group: str = ...,
module: str = ...,
attr: str = ...,
extras: list[str] = ...,
) -> EntryPoints: ...
@property
def names(self) -> set[str]: ...
@property
def groups(self) -> set[str]: ...

class SelectableGroups(dict[str, EntryPoints]): # use as dict is deprecated since 3.10
@classmethod
def load(cls: type[Self], eps: Iterable[EntryPoint]) -> Self: ...
@property
def groups(self) -> set[str]: ...
@property
def names(self) -> set[str]: ...
@overload
def select(self: Self) -> Self: ... # type: ignore[misc]
@overload
def select(
self,
*,
name: str = ...,
value: str = ...,
group: str = ...,
module: str = ...,
attr: str = ...,
extras: list[str] = ...,
) -> EntryPoints: ...

class PackagePath(pathlib.PurePosixPath):
def read_text(self, encoding: str = ...) -> str: ...
Expand Down Expand Up @@ -94,13 +143,21 @@ class Distribution:
) -> Iterable[Distribution]: ...
@staticmethod
def at(path: StrPath) -> PathDistribution: ...
@property
def metadata(self) -> Message: ...

if sys.version_info >= (3, 10):
@property
def metadata(self) -> PackageMetadata: ...
@property
def entry_points(self) -> EntryPoints: ...
else:
@property
def metadata(self) -> Message: ...
@property
def entry_points(self) -> list[EntryPoint]: ...

@property
def version(self) -> str: ...
@property
def entry_points(self) -> list[EntryPoint]: ...
@property
def files(self) -> list[PackagePath] | None: ...
@property
def requires(self) -> list[str] | None: ...
Expand Down Expand Up @@ -137,8 +194,20 @@ def distributions(*, context: DistributionFinder.Context) -> Iterable[Distributi
def distributions(
*, context: None = ..., name: str | None = ..., path: list[str] = ..., **kwargs: Any
) -> Iterable[Distribution]: ...
def metadata(distribution_name: str) -> Message: ...

if sys.version_info >= (3, 10):
def metadata(distribution_name: str) -> PackageMetadata: ...
@overload
def entry_points() -> SelectableGroups: ... # type: ignore[misc]
@overload
def entry_points(
*, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ...
) -> EntryPoints: ...

else:
def metadata(distribution_name: str) -> Message: ...
def entry_points() -> dict[str, list[EntryPoint]]: ...

def version(distribution_name: str) -> str: ...
def entry_points() -> dict[str, tuple[EntryPoint, ...]]: ...
def files(distribution_name: str) -> list[PackagePath] | None: ...
def requires(distribution_name: str) -> list[str] | None: ...