From b2b7cebb6556601ead782250c36c8075cf7d80e2 Mon Sep 17 00:00:00 2001 From: layday <31134424+layday@users.noreply.github.com> Date: Sat, 20 Nov 2021 15:32:21 +0200 Subject: [PATCH] sys.meta_path: don't require find_module() or supporting bytes paths (#6344) --- stdlib/sys.pyi | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index ab4e2f8a2..274e4b90f 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -1,6 +1,6 @@ import sys from builtins import object as _object -from importlib.abc import Loader, PathEntryFinder +from importlib.abc import PathEntryFinder from importlib.machinery import ModuleSpec from io import TextIOWrapper from types import FrameType, ModuleType, TracebackType @@ -26,12 +26,10 @@ _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) +# Intentionally omits one deprecated and one optional method of `importlib.abc.MetaPathFinder` class _MetaPathFinder(Protocol): - def find_module(self, fullname: str, path: _PathSequence | None) -> Loader | None: ... - def find_spec(self, fullname: str, path: _PathSequence | None, target: ModuleType | None = ...) -> ModuleSpec | None: ... + def find_spec(self, fullname: str, path: Sequence[str] | None, target: ModuleType | None = ...) -> ModuleSpec | None: ... # ----- sys variables ----- if sys.platform != "win32":