mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-21 11:21:19 +08:00
Use protocols instead of importlib.abc.Loader/MetaPathFinder/PathEntryFinder (#11890)
This commit is contained in:
committed by
GitHub
parent
6565e8a0a0
commit
b42e3b2e89
18
stdlib/_typeshed/importlib.pyi
Normal file
18
stdlib/_typeshed/importlib.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
# Implicit protocols used in importlib.
|
||||
# We intentionally omit deprecated and optional methods.
|
||||
|
||||
from collections.abc import Sequence
|
||||
from importlib.machinery import ModuleSpec
|
||||
from types import ModuleType
|
||||
from typing import Protocol
|
||||
|
||||
__all__ = ["LoaderProtocol", "MetaPathFinderProtocol", "PathEntryFinderProtocol"]
|
||||
|
||||
class LoaderProtocol(Protocol):
|
||||
def load_module(self, fullname: str, /) -> ModuleType: ...
|
||||
|
||||
class MetaPathFinderProtocol(Protocol):
|
||||
def find_spec(self, fullname: str, path: Sequence[str] | None, target: ModuleType | None = ..., /) -> ModuleSpec | None: ...
|
||||
|
||||
class PathEntryFinderProtocol(Protocol):
|
||||
def find_spec(self, fullname: str, target: ModuleType | None = ..., /) -> ModuleSpec | None: ...
|
||||
Reference in New Issue
Block a user