|
| 1 | +import _ast |
| 2 | +import importlib.abc |
| 3 | +import importlib.machinery |
| 4 | +import importlib.readers |
| 5 | +import sys |
| 6 | +import types |
| 7 | +from _typeshed import Incomplete, ReadableBuffer, StrOrBytesPath, StrPath |
| 8 | +from _typeshed.importlib import LoaderProtocol |
| 9 | +from collections.abc import Callable, Iterable, Mapping, MutableSequence, Sequence |
| 10 | +from importlib.machinery import ModuleSpec |
| 11 | +from importlib.metadata import DistributionFinder, PathDistribution |
| 12 | +from typing import Any, Literal |
| 13 | +from typing_extensions import deprecated |
| 14 | + |
| 15 | +path_separators: Incomplete |
| 16 | +path_sep: Incomplete |
| 17 | +path_sep_tuple: Incomplete |
| 18 | + |
| 19 | +MAGIC_NUMBER: bytes |
| 20 | + |
| 21 | +def cache_from_source(path: str, debug_override: bool | None = None, *, optimization: Any | None = None) -> str: ... |
| 22 | +def source_from_cache(path: str) -> str: ... |
| 23 | +def decode_source(source_bytes: ReadableBuffer) -> str: ... |
| 24 | +def spec_from_file_location( |
| 25 | + name: str, |
| 26 | + location: StrOrBytesPath | None = None, |
| 27 | + *, |
| 28 | + loader: LoaderProtocol | None = None, |
| 29 | + submodule_search_locations: list[str] | None = ..., |
| 30 | +) -> importlib.machinery.ModuleSpec | None: ... |
| 31 | + |
| 32 | +class WindowsRegistryFinder(importlib.abc.MetaPathFinder): |
| 33 | + if sys.version_info < (3, 12): |
| 34 | + @classmethod |
| 35 | + def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ... |
| 36 | + |
| 37 | + @classmethod |
| 38 | + def find_spec( |
| 39 | + cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None |
| 40 | + ) -> ModuleSpec | None: ... |
| 41 | + |
| 42 | +class PathFinder(importlib.abc.MetaPathFinder): |
| 43 | + if sys.version_info >= (3, 10): |
| 44 | + @staticmethod |
| 45 | + def invalidate_caches() -> None: ... |
| 46 | + else: |
| 47 | + @classmethod |
| 48 | + def invalidate_caches(cls) -> None: ... |
| 49 | + if sys.version_info >= (3, 10): |
| 50 | + @staticmethod |
| 51 | + def find_distributions(context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... |
| 52 | + else: |
| 53 | + @classmethod |
| 54 | + def find_distributions(cls, context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... |
| 55 | + |
| 56 | + @classmethod |
| 57 | + def find_spec( |
| 58 | + cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None |
| 59 | + ) -> ModuleSpec | None: ... |
| 60 | + if sys.version_info < (3, 12): |
| 61 | + @classmethod |
| 62 | + def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ... |
| 63 | + |
| 64 | +SOURCE_SUFFIXES: list[str] |
| 65 | +DEBUG_BYTECODE_SUFFIXES: list[str] |
| 66 | +OPTIMIZED_BYTECODE_SUFFIXES: list[str] |
| 67 | +BYTECODE_SUFFIXES: list[str] |
| 68 | +EXTENSION_SUFFIXES: list[str] |
| 69 | + |
| 70 | +class FileFinder(importlib.abc.PathEntryFinder): |
| 71 | + path: str |
| 72 | + def __init__(self, path: str, *loader_details: tuple[type[importlib.abc.Loader], list[str]]) -> None: ... |
| 73 | + @classmethod |
| 74 | + def path_hook( |
| 75 | + cls, *loader_details: tuple[type[importlib.abc.Loader], list[str]] |
| 76 | + ) -> Callable[[str], importlib.abc.PathEntryFinder]: ... |
| 77 | + |
| 78 | +class _LoaderBasics: |
| 79 | + def is_package(self, fullname: str) -> bool: ... |
| 80 | + def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... |
| 81 | + def exec_module(self, module: types.ModuleType) -> None: ... |
| 82 | + def load_module(self, fullname: str) -> types.ModuleType: ... |
| 83 | + |
| 84 | +class SourceLoader(_LoaderBasics): |
| 85 | + def path_mtime(self, path: str) -> float: ... |
| 86 | + def set_data(self, path: str, data: bytes) -> None: ... |
| 87 | + def get_source(self, fullname: str) -> str | None: ... |
| 88 | + def path_stats(self, path: str) -> Mapping[str, Any]: ... |
| 89 | + def source_to_code( |
| 90 | + self, data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, path: ReadableBuffer | StrPath |
| 91 | + ) -> types.CodeType: ... |
| 92 | + def get_code(self, fullname: str) -> types.CodeType | None: ... |
| 93 | + |
| 94 | +class FileLoader: |
| 95 | + name: str |
| 96 | + path: str |
| 97 | + def __init__(self, fullname: str, path: str) -> None: ... |
| 98 | + def get_data(self, path: str) -> bytes: ... |
| 99 | + def get_filename(self, fullname: str | None = None) -> str: ... |
| 100 | + def load_module(self, fullname: str | None = None) -> types.ModuleType: ... |
| 101 | + def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.FileReader: ... |
| 102 | + |
| 103 | +class SourceFileLoader(FileLoader, SourceLoader, importlib.abc.FileLoader, importlib.abc.SourceLoader): # type: ignore[misc] # Cannot determine consistent method resolution order - ABCs create circular inheritance |
| 104 | + def set_data(self, path: str, data: ReadableBuffer, *, _mode: int = 0o666) -> None: ... |
| 105 | + def path_stats(self, path: str) -> Mapping[str, Any]: ... |
| 106 | + |
| 107 | +class SourcelessFileLoader(FileLoader, _LoaderBasics, importlib.abc.FileLoader): # type: ignore[misc] # Cannot determine consistent method resolution order - ABCs create circular inheritance |
| 108 | + def get_code(self, fullname: str) -> types.CodeType | None: ... |
| 109 | + def get_source(self, fullname: str) -> None: ... |
| 110 | + |
| 111 | +class ExtensionFileLoader(FileLoader, _LoaderBasics, importlib.abc.ExecutionLoader): |
| 112 | + def __init__(self, name: str, path: str) -> None: ... |
| 113 | + def get_filename(self, name: str | None = None) -> str: ... |
| 114 | + def get_source(self, fullname: str) -> None: ... |
| 115 | + def create_module(self, spec: ModuleSpec) -> types.ModuleType: ... |
| 116 | + def exec_module(self, module: types.ModuleType) -> None: ... |
| 117 | + def get_code(self, fullname: str) -> None: ... |
| 118 | + def __eq__(self, other: object) -> bool: ... |
| 119 | + def __hash__(self) -> int: ... |
| 120 | + |
| 121 | +if sys.version_info >= (3, 11): |
| 122 | + class NamespaceLoader(importlib.abc.InspectLoader): |
| 123 | + def __init__( |
| 124 | + self, name: str, path: MutableSequence[str], path_finder: Callable[[str, tuple[str, ...]], ModuleSpec] |
| 125 | + ) -> None: ... |
| 126 | + def is_package(self, fullname: str) -> Literal[True]: ... |
| 127 | + def get_source(self, fullname: str) -> Literal[""]: ... |
| 128 | + def get_code(self, fullname: str) -> types.CodeType: ... |
| 129 | + def create_module(self, spec: ModuleSpec) -> None: ... |
| 130 | + def exec_module(self, module: types.ModuleType) -> None: ... |
| 131 | + @deprecated("load_module() is deprecated; use exec_module() instead") |
| 132 | + def load_module(self, fullname: str) -> types.ModuleType: ... |
| 133 | + def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... |
| 134 | + if sys.version_info < (3, 12): |
| 135 | + @staticmethod |
| 136 | + @deprecated("module_repr() is deprecated, and has been removed in Python 3.12") |
| 137 | + def module_repr(module: types.ModuleType) -> str: ... |
0 commit comments