massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / imp.pyi
1 import types
2 from _typeshed import StrPath
3 from os import PathLike
4 from typing import IO, Any, Protocol, TypeVar
5
6 from _imp import (
7     acquire_lock as acquire_lock,
8     create_dynamic as create_dynamic,
9     get_frozen_object as get_frozen_object,
10     init_frozen as init_frozen,
11     is_builtin as is_builtin,
12     is_frozen as is_frozen,
13     is_frozen_package as is_frozen_package,
14     lock_held as lock_held,
15     release_lock as release_lock,
16 )
17
18 _T = TypeVar("_T")
19
20 SEARCH_ERROR: int
21 PY_SOURCE: int
22 PY_COMPILED: int
23 C_EXTENSION: int
24 PY_RESOURCE: int
25 PKG_DIRECTORY: int
26 C_BUILTIN: int
27 PY_FROZEN: int
28 PY_CODERESOURCE: int
29 IMP_HOOK: int
30
31 def new_module(name: str) -> types.ModuleType: ...
32 def get_magic() -> bytes: ...
33 def get_tag() -> str: ...
34 def cache_from_source(path: StrPath, debug_override: bool | None = ...) -> str: ...
35 def source_from_cache(path: StrPath) -> str: ...
36 def get_suffixes() -> list[tuple[str, str, int]]: ...
37
38 class NullImporter:
39     def __init__(self, path: StrPath) -> None: ...
40     def find_module(self, fullname: Any) -> None: ...
41
42 # Technically, a text file has to support a slightly different set of operations than a binary file,
43 # but we ignore that here.
44 class _FileLike(Protocol):
45     closed: bool
46     mode: str
47     def read(self) -> str | bytes: ...
48     def close(self) -> Any: ...
49     def __enter__(self) -> Any: ...
50     def __exit__(self, *args: Any) -> Any: ...
51
52 # PathLike doesn't work for the pathname argument here
53 def load_source(name: str, pathname: str, file: _FileLike | None = ...) -> types.ModuleType: ...
54 def load_compiled(name: str, pathname: str, file: _FileLike | None = ...) -> types.ModuleType: ...
55 def load_package(name: str, path: StrPath) -> types.ModuleType: ...
56 def load_module(name: str, file: _FileLike | None, filename: str, details: tuple[str, str, int]) -> types.ModuleType: ...
57
58 # IO[Any] is a TextIOWrapper if name is a .py file, and a FileIO otherwise.
59 def find_module(
60     name: str, path: None | list[str] | list[PathLike[str]] | list[StrPath] = ...
61 ) -> tuple[IO[Any], str, tuple[str, str, int]]: ...
62 def reload(module: types.ModuleType) -> types.ModuleType: ...
63 def init_builtin(name: str) -> types.ModuleType | None: ...
64 def load_dynamic(name: str, path: str, file: Any = ...) -> types.ModuleType: ...  # file argument is ignored