diff --git a/python/helpers/typeshed/stdlib/3/_importlib_modulespec.pyi b/python/helpers/typeshed/stdlib/3/_importlib_modulespec.pyi new file mode 100644 index 000000000000..6ce54917024f --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/_importlib_modulespec.pyi @@ -0,0 +1,40 @@ +# ModuleSpec, ModuleType, Loader are part of a dependency cycle. +# They are officially defined/exported in other places: +# +# - ModuleType in types +# - Loader in importlib.abc +# - ModuleSpec in importlib.machinery (3.4 and later only) + +from abc import ABCMeta +import sys +from typing import Any, Dict, List, Optional + +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] + origin = ... # type: Optional[str] + submodule_search_locations = ... # type: Optional[List[str]] + loader_state = ... # type: Any + cached = ... # type: Optional[str] + parent = ... # type: Optional[str] + has_location = ... # type: bool + +class ModuleType: + __name__ = ... # type: str + __file__ = ... # type: str + __dict__ = ... # type: Dict[str, Any] + __loader__ = ... # type: Optional[Loader] + __package__ = ... # type: Optional[str] + __spec__ = ... # type: Optional[ModuleSpec] + def __init__(self, name: str, doc: Optional[str] = ...) -> None: ... + +class Loader(metaclass=ABCMeta): + def load_module(self, fullname: str) -> ModuleType: ... + def module_repr(self, module: ModuleType) -> str: ... + def create_module(self, spec: ModuleSpec) -> Optional[ModuleType]: ... + # Not defined on the actual class for backwards-compatibility reasons, + # but expected in new code. + def exec_module(self, module: ModuleType) -> None: ... diff --git a/python/tools/src/com/jetbrains/python/tools/PyTypeShedSync.kts b/python/tools/src/com/jetbrains/python/tools/PyTypeShedSync.kts index 538d303f0972..c49c4ee577ab 100644 --- a/python/tools/src/com/jetbrains/python/tools/PyTypeShedSync.kts +++ b/python/tools/src/com/jetbrains/python/tools/PyTypeShedSync.kts @@ -22,7 +22,7 @@ sync(repo, bundled) val whiteList = setOf("typing", "six", "__builtin__", "builtins", "exceptions", "types", "datetime", "functools", "shutil", "re", "time", "argparse", "uuid", "threading", "signal", "collections", "subprocess", "math", "queue", "socket", "sqlite3", "attr", - "pathlib", "io", "_io", "itertools", "ssl", "multiprocessing", "asyncio", "mock", "unittest") + "pathlib", "io", "_io", "itertools", "ssl", "multiprocessing", "asyncio", "mock", "unittest", "_importlib_modulespec") clean(topLevelPackages(bundled), whiteList)