|
| 1 | +import importlib.abc |
| 2 | +import sys |
| 3 | +import types |
| 4 | +from typing import Any, Callable, List, Optional, Sequence, Tuple, Union |
| 5 | + |
| 6 | +# ModuleSpec is defined in this module, but for circular import reasons exists |
| 7 | +# in its own stub file. |
| 8 | +from importlib._modulespec import ModuleSpec |
| 9 | + |
| 10 | +class BuiltinImporter(importlib.abc.MetaPathFinder, |
| 11 | + importlib.abc.InspectLoader): |
| 12 | + # MetaPathFinder |
| 13 | + @classmethod |
| 14 | + def find_module(cls, fullname: str, |
| 15 | + path: Optional[Sequence[importlib.abc._Path]] |
| 16 | + ) -> Optional[importlib.abc.Loader]: |
| 17 | + ... |
| 18 | + if sys.version_info >= (3, 4): |
| 19 | + @classmethod |
| 20 | + def find_spec(cls, fullname: str, |
| 21 | + path: Optional[Sequence[importlib.abc._Path]], |
| 22 | + target: types.ModuleType = None) -> Optional[ModuleSpec]: |
| 23 | + ... |
| 24 | + # InspectLoader |
| 25 | + @classmethod |
| 26 | + def is_package(cls, fullname: str) -> bool: ... |
| 27 | + @classmethod |
| 28 | + def load_module(cls, fullname: str) -> types.ModuleType: ... |
| 29 | + @classmethod |
| 30 | + def get_code(cls, fullname: str) -> None: ... # type: ignore |
| 31 | + @classmethod |
| 32 | + def get_source(cls, fullname: str) -> None: ... # type: ignore |
| 33 | + # Loader |
| 34 | + @classmethod |
| 35 | + def load_module(cls, fullname: str) -> types.ModuleType: ... |
| 36 | + if sys.version_info >= (3, 3): |
| 37 | + @staticmethod |
| 38 | + def module_repr(module: types.ModuleType) -> str: ... # type: ignore |
| 39 | + if sys.version_info >= (3, 4): |
| 40 | + @classmethod |
| 41 | + def create_module(cls, spec: ModuleSpec) -> Optional[types.ModuleType]: |
| 42 | + ... |
| 43 | + @classmethod |
| 44 | + def exec_module(cls, module: types.ModuleType) -> None: ... |
| 45 | + |
| 46 | +class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): |
| 47 | + # MetaPathFinder |
| 48 | + @classmethod |
| 49 | + def find_module(cls, fullname: str, |
| 50 | + path: Optional[Sequence[importlib.abc._Path]] |
| 51 | + ) -> Optional[importlib.abc.Loader]: |
| 52 | + ... |
| 53 | + if sys.version_info >= (3, 4): |
| 54 | + @classmethod |
| 55 | + def find_spec(cls, fullname: str, |
| 56 | + path: Optional[Sequence[importlib.abc._Path]], |
| 57 | + target: types.ModuleType = None) -> Optional[ModuleSpec]: |
| 58 | + ... |
| 59 | + # InspectLoader |
| 60 | + @classmethod |
| 61 | + def is_package(cls, fullname: str) -> bool: ... |
| 62 | + @classmethod |
| 63 | + def load_module(cls, fullname: str) -> types.ModuleType: ... |
| 64 | + @classmethod |
| 65 | + def get_code(cls, fullname: str) -> None: ... # type: ignore |
| 66 | + @classmethod |
| 67 | + def get_source(cls, fullname: str) -> None: ... # type: ignore |
| 68 | + # Loader |
| 69 | + @classmethod |
| 70 | + def load_module(cls, fullname: str) -> types.ModuleType: ... |
| 71 | + if sys.version_info >= (3, 3): |
| 72 | + @staticmethod |
| 73 | + def module_repr(module: types.ModuleType) -> str: ... # type: ignore |
| 74 | + if sys.version_info >= (3, 4): |
| 75 | + @classmethod |
| 76 | + def create_module(cls, spec: ModuleSpec) -> Optional[types.ModuleType]: |
| 77 | + ... |
| 78 | + @staticmethod |
| 79 | + def exec_module(module: types.ModuleType) -> None: ... # type: ignore |
| 80 | + |
| 81 | +class WindowsRegisteryFinder(importlib.abc.MetaPathFinder): |
| 82 | + @classmethod |
| 83 | + def find_module(cls, fullname: str, |
| 84 | + path: Optional[Sequence[importlib.abc._Path]] |
| 85 | + ) -> Optional[importlib.abc.Loader]: |
| 86 | + ... |
| 87 | + if sys.version_info >= (3, 4): |
| 88 | + @classmethod |
| 89 | + def find_spec(cls, fullname: str, |
| 90 | + path: Optional[Sequence[importlib.abc._Path]], |
| 91 | + target: types.ModuleType = None) -> Optional[ModuleSpec]: |
| 92 | + ... |
| 93 | + |
| 94 | +class PathFinder(importlib.abc.MetaPathFinder): ... |
| 95 | + |
| 96 | +if sys.version_info >= (3, 3): |
| 97 | + SOURCE_SUFFIXES = ... # type: List[str] |
| 98 | + DEBUG_BYTECODE_SUFFIXES = ... # type: List[str] |
| 99 | + OPTIMIZED_BYTECODE_SUFFIXES = ... # type: List[str] |
| 100 | + BYTECODE_SUFFIXES = ... # type: List[str] |
| 101 | + EXTENSION_SUFFIXES = ... # type: List[str] |
| 102 | + |
| 103 | + def all_suffixes() -> List[str]: ... |
| 104 | + |
| 105 | + class FileFinder(importlib.abc.PathEntryFinder): |
| 106 | + path = ... # type: str |
| 107 | + def __init__(self, path: str, |
| 108 | + *loader_details: Tuple[importlib.abc.Loader, List[str]] |
| 109 | + ) -> None: ... |
| 110 | + @classmethod |
| 111 | + def path_hook(*loader_details: Tuple[importlib.abc.Loader, List[str]] |
| 112 | + ) -> Callable[[str], importlib.abc.PathEntryFinder]: ... |
| 113 | + |
| 114 | + class SourceFileLoader(importlib.abc.FileLoader, |
| 115 | + importlib.abc.SourceLoader): |
| 116 | + ... |
| 117 | + |
| 118 | + class SourcelessFileLoader(importlib.abc.FileLoader, |
| 119 | + importlib.abc.SourceLoader): |
| 120 | + ... |
| 121 | + |
| 122 | + class ExtensionFileLoader(importlib.abc.ExecutionLoader): |
| 123 | + def get_filename(self, fullname: str) -> importlib.abc._Path: ... |
| 124 | + def get_source(self, fullname: str) -> None: ... # type: ignore |
0 commit comments