|
| 1 | +# Stubs for importlib._bootstrap (Python 3.4) |
| 2 | + |
| 3 | +from importlib.abc import Loader |
| 4 | + |
| 5 | +from typing import ( |
| 6 | + Any, Optional, Sequence, Callable, Iterator, Tuple, Iterable, Mapping, Union |
| 7 | +) |
| 8 | +from types import TracebackType, ModuleType, CodeType |
| 9 | +import _thread |
| 10 | +from ast import AST |
| 11 | + |
| 12 | +class _ManageReload: |
| 13 | + def __init__(self, name: str) -> None: ... |
| 14 | + def __enter__(self) -> None: ... |
| 15 | + def __exit__(self, exc_type: Optional[type], exc_value: |
| 16 | + Optional[BaseException], traceback: TracebackType) \ |
| 17 | + -> Optional[bool]: ... |
| 18 | + |
| 19 | +class _DeadlockError(RuntimeError): ... |
| 20 | + |
| 21 | +class _ModuleLock: |
| 22 | + lock = ... # type: _thread.LockType |
| 23 | + wakeup = ... # type: _thread.LockType |
| 24 | + name = ... # type: str |
| 25 | + owner = ... # type: Optional[int] |
| 26 | + count = ... # type: int |
| 27 | + waiters = ... # type: int |
| 28 | + def __init__(self, name: str) -> None: ... |
| 29 | + def has_deadlock(self) -> bool: ... |
| 30 | + def acquire(self) -> None: ... |
| 31 | + def release(self) -> None: ... |
| 32 | + |
| 33 | +class _DummyModuleLock: |
| 34 | + name = ... # type: str |
| 35 | + count = ... # type: int |
| 36 | + def __init__(self, name: str) -> None: ... |
| 37 | + def acquire(self) -> None: ... |
| 38 | + def release(self) -> None: ... |
| 39 | + |
| 40 | +class _ModuleLockManager: |
| 41 | + def __init__(self, name: str) -> None: ... |
| 42 | + def __enter__(self) -> None: ... |
| 43 | + def __exit__(self, exc_type: Optional[type], exc_value: |
| 44 | + Optional[BaseException], traceback: TracebackType) \ |
| 45 | + -> Optional[bool]: ... |
| 46 | + |
| 47 | +MAGIC_NUMBER = ... # type: bytes |
| 48 | +SOURCE_SUFFIXES = ... # type: List[str] |
| 49 | +DEBUG_BYTECODE_SUFFIXES = ... # type: List[str] |
| 50 | +OPTIMIZED_BYTECODE_SUFFIXES = ... # type: List[str] |
| 51 | + |
| 52 | +def cache_from_source(path: str, debug_override: Optional[bool] = ...) -> str: ... |
| 53 | +def source_from_cache(path: str) -> str: ... |
| 54 | +def decode_source(source_bytes: bytes) -> str: ... |
| 55 | + |
| 56 | +class _installed_safely: |
| 57 | + def __init__(self, module: ModuleType) -> None: ... |
| 58 | + def __enter__(self) -> None: ... |
| 59 | + def __exit__(self, exc_type: Optional[type], exc_value: |
| 60 | + Optional[BaseException], traceback: TracebackType) \ |
| 61 | + -> Optional[bool]: ... |
| 62 | + |
| 63 | +# TODO find real type of loader_state |
| 64 | +class ModuleSpec: |
| 65 | + name = ... # type: str |
| 66 | + loader = ... # type: Loader |
| 67 | + origin = ... # type: str |
| 68 | + loader_state = ... # type: Optional[Any] |
| 69 | + submodule_search_locations = ... # type: Sequence[str] |
| 70 | + def __init__(self, name: str, loader: Loader, *, |
| 71 | + origin: Optional[str] = ..., loader_state: Optional[Any] = ..., |
| 72 | + is_package: Optional[bool] = ...) -> None: ... |
| 73 | + def __eq__(self, other: Any) -> bool: ... |
| 74 | + @property |
| 75 | + def cached(self) -> Optional[str]: ... |
| 76 | + @cached.setter |
| 77 | + def cached(self, cached: Optional[str]) -> None: ... |
| 78 | + @property |
| 79 | + def parent(self) -> str: ... |
| 80 | + @property |
| 81 | + def has_location(self) -> bool: ... |
| 82 | + @has_location.setter |
| 83 | + def has_location(self, value: bool) -> None: ... |
| 84 | + |
| 85 | +def spec_from_loader(name: str, loader: Loader, *, origin: Optional[str] = ..., |
| 86 | + is_package: Optional[bool] = ...) -> ModuleSpec: ... |
| 87 | +def spec_from_file_location(name: str, location: Optional[str] = ..., *, |
| 88 | + loader: Optional[Loader] = ..., |
| 89 | + submodule_search_locations: List[str] = ...) \ |
| 90 | + -> ModuleSpec: ... |
| 91 | + |
| 92 | +class _SpecMethods: |
| 93 | + spec = ... # type: ModuleSpec |
| 94 | + def __init__(self, spec: ModuleSpec) -> None: ... |
| 95 | + def module_repr(self) -> str: ... |
| 96 | + def init_module_attrs(self, module: ModuleType, *, _override: bool = ..., |
| 97 | + _force_name: bool = ...) -> None: ... |
| 98 | + def create(self) -> ModuleType: ... |
| 99 | + def exec(self, module: ModuleType) -> ModuleType: ... |
| 100 | + def load(self) -> ModuleType: ... |
| 101 | + |
| 102 | +# TODO find real type of target |
| 103 | +class BuiltinImporter: |
| 104 | + @staticmethod |
| 105 | + def module_repr(module: ModuleType) -> str: ... |
| 106 | + @classmethod |
| 107 | + def find_spec(cls, fullname: str, path: Optional[str] = ..., |
| 108 | + target: Optional[Any] = ...) -> Optional[ModuleSpec]: ... |
| 109 | + @classmethod |
| 110 | + def find_module(cls, fullname: str, path: Optional[str] = ...) \ |
| 111 | + -> Optional[Loader]: ... |
| 112 | + @classmethod |
| 113 | + def load_module(cls, fullname: str) -> ModuleType: ... |
| 114 | + @classmethod |
| 115 | + def get_code(cls, fullname: str) -> None: ... |
| 116 | + @classmethod |
| 117 | + def get_source(cls, fullname: str) -> None: ... |
| 118 | + @classmethod |
| 119 | + def is_package(cls, fullname: str) -> bool: ... |
| 120 | + |
| 121 | +class FrozenImporter: |
| 122 | + @staticmethod |
| 123 | + def module_repr(module: ModuleType) -> str: ... |
| 124 | + @classmethod |
| 125 | + def find_spec(cls, fullname: str, path: Optional[str] = ..., |
| 126 | + target: Optional[Any] = ...) -> Optional[ModuleSpec]: ... |
| 127 | + @classmethod |
| 128 | + def find_module(cls, fullname: str, path: Optional[str] = ...) \ |
| 129 | + -> Optional[Loader]: ... |
| 130 | + @staticmethod |
| 131 | + def exec_module(module: ModuleType) -> None: ... |
| 132 | + @classmethod |
| 133 | + def load_module(cls, fullname: str) -> ModuleType: ... |
| 134 | + @classmethod |
| 135 | + def get_code(cls, fullname: str) -> CodeType: ... |
| 136 | + @classmethod |
| 137 | + def get_source(cls, fullname: str) -> None: ... |
| 138 | + @classmethod |
| 139 | + def is_package(cls, fullname: str) -> bool: ... |
| 140 | + |
| 141 | +class WindowsRegistryFinder: |
| 142 | + REGISTRY_KEY = ... # type: str |
| 143 | + REGISTRY_KEY_DEBUG = ... # type: str |
| 144 | + DEBUG_BUILD = ... # type: bool |
| 145 | + @classmethod |
| 146 | + def find_spec(cls, fullname: str, path: Optional[str] = ..., |
| 147 | + target: Optional[Any] = ...) -> Optional[ModuleSpec]: ... |
| 148 | + @classmethod |
| 149 | + def find_module(cls, fullname: str, path: Optional[str] = ...) \ |
| 150 | + -> Optional[Loader]: ... |
| 151 | + |
| 152 | +class _LoaderBasics: |
| 153 | + def is_package(cls, fullname: str) -> bool: ... |
| 154 | + def exec_module(module: ModuleType) -> bool: ... |
| 155 | + # TODO should be an object |
| 156 | + def load_module(self, fullname: str) -> ModuleType: ... |
| 157 | + |
| 158 | +class SourceLoader(_LoaderBasics): |
| 159 | + def path_mtime(self, path: str) -> int: ... |
| 160 | + def path_stats(self, path: str) -> Dict[str, int]: ... |
| 161 | + def set_data(self, path: str, data: bytes) -> None: ... |
| 162 | + def get_source(self, fullname: str) -> str: ... |
| 163 | + def source_to_code(self, data: Union[str, bytes, AST], path: str, *, |
| 164 | + _optimize: int = ...) -> CodeType: ... |
| 165 | + def get_code(self, fullname: str) -> CodeType: ... |
| 166 | + |
| 167 | +class FileLoader: |
| 168 | + name = ... # type: str |
| 169 | + path = ... # type: str |
| 170 | + def __init__(self, fullname: str, path: str) -> None: ... |
| 171 | + def __eq__(self, other: Any) -> bool: ... |
| 172 | + def __hash__(self) -> int: ... |
| 173 | + def load_module(self, fullname: str) -> ModuleType: ... |
| 174 | + def get_filename(self, fullname: str) -> str: ... |
| 175 | + def get_data(self, path: str) -> bytes: ... |
| 176 | + |
| 177 | +class SourceFileLoader(FileLoader, SourceLoader): |
| 178 | + def set_data(self, path: str, data: bytes, *, _mode: int = ...) -> None: ... |
| 179 | + |
| 180 | +class SourcelessFileLoader(FileLoader, _LoaderBasics): |
| 181 | + def get_code(self, fullname: str) -> CodeType: ... |
| 182 | + def get_source(self, fullname: str) -> str: ... |
| 183 | + |
| 184 | +EXTENSION_SUFFIXES = ... # type: List[str] |
| 185 | + |
| 186 | +class ExtensionFileLoader: |
| 187 | + name = ... # type: str |
| 188 | + path = ... # type: str |
| 189 | + def __init__(self, name: str, path: List[str]) -> None: ... |
| 190 | + def __eq__(self, other: Any) -> bool: ... |
| 191 | + def __hash__(self) -> int: ... |
| 192 | + def load_module(self, fullname: str) -> ModuleType: ... |
| 193 | + def is_package(cls, fullname: str) -> bool: ... |
| 194 | + def get_code(self, fullname: str) -> None: ... |
| 195 | + def get_source(self, fullname: str) -> None: ... |
| 196 | + def get_filename(self, fullname: str) -> str: ... |
| 197 | + |
| 198 | +class _NamespacePath: |
| 199 | + def __init__(self, name: str, path: str, |
| 200 | + path_finder: Callable[[str, Tuple[str]], ModuleSpec]) \ |
| 201 | + -> None: ... |
| 202 | + def __iter__(self) -> Iterator[str]: ... |
| 203 | + def __len__(self) -> int: ... |
| 204 | + def __contains__(self, item: str) -> bool: ... |
| 205 | + def append(self, item: str) -> None: ... |
| 206 | + |
| 207 | +class _NamespaceLoader: |
| 208 | + def __init__(self, name: str, path: str, |
| 209 | + path_finder: Callable[[str, Tuple[str]], ModuleSpec]) \ |
| 210 | + -> None: ... |
| 211 | + @classmethod |
| 212 | + def module_repr(self) -> str: ... |
| 213 | + def is_package(cls, fullname: str) -> bool: ... |
| 214 | + def get_source(self, fullname: str) -> None: ... |
| 215 | + def get_code(self, fullname: str) -> None: ... |
| 216 | + def exec_module(module: ModuleType) -> None: ... |
| 217 | + def load_module(self, fullname: str) -> ModuleType: ... |
| 218 | + |
| 219 | +class PathFinder: |
| 220 | + @classmethod |
| 221 | + def invalidate_caches(cls) -> None: ... |
| 222 | + @classmethod |
| 223 | + def find_spec(cls, fullname: str, path: Optional[str] = ..., |
| 224 | + target: Optional[Any] = ...) -> Optional[ModuleSpec]: ... |
| 225 | + @classmethod |
| 226 | + def find_module(cls, fullname: str, path: Optional[str] = ...) \ |
| 227 | + -> Optional[Loader]: ... |
| 228 | + |
| 229 | +# TODO find real type of target |
| 230 | +class FileFinder: |
| 231 | + path = ... # type: str |
| 232 | + def __init__(self, path: str, |
| 233 | + *loader_details: Tuple[Loader, Iterable[str]]) -> None: ... |
| 234 | + def invalidate_caches(self) -> None: ... |
| 235 | + # TODO should be an object |
| 236 | + def find_module(cls, fullname: str, path: Optional[str] = ...) \ |
| 237 | + -> Optional[Loader]: ... |
| 238 | + def find_loader(self, fullname: str) -> Tuple[Optional[Loader], List[str]]: |
| 239 | + ... |
| 240 | + def find_spec(self, fullname: str, target: Optional[Any] = ...) \ |
| 241 | + -> Optional[ModuleSpec]: ... |
| 242 | + @classmethod |
| 243 | + def path_hook(cls, *loader_details: Tuple[Loader, Iterable[str]]) \ |
| 244 | + -> Callable[[str], 'FileFinder']: ... |
| 245 | + |
| 246 | +class _ImportLockContext: |
| 247 | + def __enter__(self) -> None: ... |
| 248 | + def __exit__(self, exc_type: Optional[type], exc_value: |
| 249 | + Optional[BaseException], traceback: TracebackType) \ |
| 250 | + -> Optional[bool]: ... |
| 251 | + |
| 252 | +def _calc___package__(globals: Mapping[str, Optional[str]]) -> str: ... |
| 253 | +# TODO find real type of locals |
| 254 | +def __import__(name: str, globals: Optional[Mapping[str, Optional[str]]] = ..., |
| 255 | + locals: Optional[Any] = ..., fromlist: List[str] = ..., |
| 256 | + level: int = ...) -> ModuleType: ... |
| 257 | + |
| 258 | +BYTECODE_SUFFIXES = ... # type: str |
0 commit comments