massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / coc-python-data / languageServer.0.5.59 / Typeshed / stdlib / 3 / importlib / abc.pyi
1 from abc import ABCMeta, abstractmethod\r
2 import os\r
3 import sys\r
4 import types\r
5 from typing import Any, IO, Iterator, Mapping, Optional, Sequence, Tuple, Union\r
6 \r
7 # Loader is exported from this module, but for circular import reasons\r
8 # exists in its own stub file (with ModuleSpec and ModuleType).\r
9 from _importlib_modulespec import Loader as Loader  # Exported\r
10 \r
11 from _importlib_modulespec import ModuleSpec\r
12 \r
13 _Path = Union[bytes, str]\r
14 \r
15 class Finder(metaclass=ABCMeta):\r
16     ...\r
17     # Technically this class defines the following method, but its subclasses\r
18     # in this module violate its signature. Since this class is deprecated, it's\r
19     # easier to simply ignore that this method exists.\r
20     # @abstractmethod\r
21     # def find_module(self, fullname: str,\r
22     #                 path: Optional[Sequence[_Path]] = ...) -> Optional[Loader]: ...\r
23 \r
24 class ResourceLoader(Loader):\r
25     @abstractmethod\r
26     def get_data(self, path: _Path) -> bytes: ...\r
27 \r
28 class InspectLoader(Loader):\r
29     def is_package(self, fullname: str) -> bool: ...\r
30     def get_code(self, fullname: str) -> Optional[types.CodeType]: ...\r
31     def load_module(self, fullname: str) -> types.ModuleType: ...\r
32     @abstractmethod\r
33     def get_source(self, fullname: str) -> Optional[str]: ...\r
34     def exec_module(self, module: types.ModuleType) -> None: ...\r
35     if sys.version_info < (3, 5):\r
36         def source_to_code(self, data: Union[bytes, str],\r
37                            path: str = ...) -> types.CodeType: ...\r
38     else:\r
39         @staticmethod\r
40         def source_to_code(data: Union[bytes, str],\r
41                            path: str = ...) -> types.CodeType: ...\r
42 \r
43 class ExecutionLoader(InspectLoader):\r
44     @abstractmethod\r
45     def get_filename(self, fullname: str) -> _Path: ...\r
46     def get_code(self, fullname: str) -> Optional[types.CodeType]: ...\r
47 \r
48 class SourceLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta):\r
49     def path_mtime(self, path: _Path) -> Union[int, float]: ...\r
50     def set_data(self, path: _Path, data: bytes) -> None: ...\r
51     def get_source(self, fullname: str) -> Optional[str]: ...\r
52     def path_stats(self, path: _Path) -> Mapping[str, Any]: ...\r
53 \r
54 \r
55 class MetaPathFinder(Finder):\r
56     def find_module(self, fullname: str,\r
57                     path: Optional[Sequence[_Path]]) -> Optional[Loader]:\r
58         ...\r
59     def invalidate_caches(self) -> None: ...\r
60     # Not defined on the actual class, but expected to exist.\r
61     def find_spec(\r
62         self, fullname: str, path: Optional[Sequence[_Path]],\r
63         target: Optional[types.ModuleType] = ...\r
64     ) -> Optional[ModuleSpec]:\r
65         ...\r
66 \r
67 class PathEntryFinder(Finder):\r
68     def find_module(self, fullname: str) -> Optional[Loader]: ...\r
69     def find_loader(\r
70         self, fullname: str\r
71     ) -> Tuple[Optional[Loader], Sequence[_Path]]: ...\r
72     def invalidate_caches(self) -> None: ...\r
73     # Not defined on the actual class, but expected to exist.\r
74     def find_spec(\r
75         self, fullname: str,\r
76         target: Optional[types.ModuleType] = ...\r
77     ) -> Optional[ModuleSpec]: ...\r
78 \r
79 class FileLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta):\r
80     name = ...  # type: str\r
81     path = ...  # type: _Path\r
82     def __init__(self, fullname: str, path: _Path) -> None: ...\r
83     def get_data(self, path: _Path) -> bytes: ...\r
84     def get_filename(self, fullname: str) -> _Path: ...\r
85 \r
86 if sys.version_info >= (3, 7):\r
87     _PathLike = Union[bytes, str, os.PathLike[Any]]\r
88 \r
89     class ResourceReader(metaclass=ABCMeta):\r
90         @abstractmethod\r
91         def open_resource(self, resource: _PathLike) -> IO[bytes]: ...\r
92         @abstractmethod\r
93         def resource_path(self, resource: _PathLike) -> str: ...\r
94         @abstractmethod\r
95         def is_resource(self, name: str) -> bool: ...\r
96         @abstractmethod\r
97         def contents(self) -> Iterator[str]: ...\r