Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stdlib/importlib/abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SourceLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta):
def get_source(self, fullname: str) -> Optional[str]: ...
def path_stats(self, path: _Path) -> Mapping[str, Any]: ...

# Please keep in sync with sys._MetaPathFinder
class MetaPathFinder(Finder):
def find_module(self, fullname: str, path: Optional[Sequence[_Path]]) -> Optional[Loader]: ...
def invalidate_caches(self) -> None: ...
Expand Down
14 changes: 12 additions & 2 deletions stdlib/sys.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from builtins import object as _object
from importlib.abc import MetaPathFinder, PathEntryFinder
from importlib.abc import Loader, PathEntryFinder
from importlib.machinery import ModuleSpec
from types import FrameType, ModuleType, TracebackType
from typing import (
Any,
Expand All @@ -10,6 +11,7 @@ from typing import (
List,
NoReturn,
Optional,
Protocol,
Sequence,
TextIO,
Tuple,
Expand All @@ -24,6 +26,14 @@ _T = TypeVar("_T")
# The following type alias are stub-only and do not exist during runtime
_ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType]
_OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]]
_PathSequence = Sequence[Union[bytes, str]]

# Unlike importlib.abc.MetaPathFinder, invalidate_caches() might not exist (see python docs)
class _MetaPathFinder(Protocol):
def find_module(self, fullname: str, path: Optional[_PathSequence]) -> Optional[Loader]: ...
def find_spec(
self, fullname: str, path: Optional[_PathSequence], target: Optional[ModuleType] = ...
) -> Optional[ModuleSpec]: ...

# ----- sys variables -----
if sys.platform != "win32":
Expand All @@ -48,7 +58,7 @@ last_value: Optional[BaseException]
last_traceback: Optional[TracebackType]
maxsize: int
maxunicode: int
meta_path: List[MetaPathFinder]
meta_path: List[_MetaPathFinder]
modules: Dict[str, ModuleType]
path: List[str]
path_hooks: List[Any] # TODO precise type; function, path to finder
Expand Down