diff --git a/stdlib/3/_importlib_modulespec.pyi b/stdlib/3/_importlib_modulespec.pyi index 6ce54917024f..eca7a3252ca2 100644 --- a/stdlib/3/_importlib_modulespec.pyi +++ b/stdlib/3/_importlib_modulespec.pyi @@ -4,17 +4,22 @@ # - ModuleType in types # - Loader in importlib.abc # - ModuleSpec in importlib.machinery (3.4 and later only) +# +# _Loader is the PEP-451-defined interface for a loader type/object. from abc import ABCMeta import sys -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List, Optional, Protocol + +class _Loader(Protocol): + def load_module(self, fullname: str) -> ModuleType: ... class ModuleSpec: def __init__(self, name: str, loader: Optional[Loader], *, origin: Optional[str] = ..., loader_state: Any = ..., is_package: Optional[bool] = ...) -> None: ... name = ... # type: str - loader = ... # type: Optional[Loader] + loader = ... # type: Optional[_Loader] origin = ... # type: Optional[str] submodule_search_locations = ... # type: Optional[List[str]] loader_state = ... # type: Any @@ -26,7 +31,7 @@ class ModuleType: __name__ = ... # type: str __file__ = ... # type: str __dict__ = ... # type: Dict[str, Any] - __loader__ = ... # type: Optional[Loader] + __loader__ = ... # type: Optional[_Loader] __package__ = ... # type: Optional[str] __spec__ = ... # type: Optional[ModuleSpec] def __init__(self, name: str, doc: Optional[str] = ...) -> None: ...