From 838e02334ec8dd333109b4b196cbc2b76bd39ab7 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Wed, 20 Nov 2019 11:29:05 +0100 Subject: [PATCH] Fix type of imp.find_module() (#3465) find_module is documented to return a tuple (file, pathname, description) where "file" is open file object and "description" a tuple (suffix, mode, type). The type of "file" was wrong ("str" instead of "IO[Any]") as well as that of "suffix" ("IO[Any]" instead of "str"); probably those type definitions were swapped. Fixes #3466. --- stdlib/2/imp.pyi | 2 +- stdlib/3/imp.pyi | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/2/imp.pyi b/stdlib/2/imp.pyi index 409fecb5b..8ff9e1aed 100644 --- a/stdlib/2/imp.pyi +++ b/stdlib/2/imp.pyi @@ -15,7 +15,7 @@ PY_SOURCE: int SEARCH_ERROR: int def acquire_lock() -> None: ... -def find_module(name: str, path: Iterable[str] = ...) -> Optional[Tuple[str, str, Tuple[str, str, int]]]: ... +def find_module(name: str, path: Iterable[str] = ...) -> Optional[Tuple[IO[Any], str, Tuple[str, str, int]]]: ... def get_magic() -> str: ... def get_suffixes() -> List[Tuple[str, str, int]]: ... def init_builtin(name: str) -> types.ModuleType: ... diff --git a/stdlib/3/imp.pyi b/stdlib/3/imp.pyi index 9ba615021..5f17fe5d2 100644 --- a/stdlib/3/imp.pyi +++ b/stdlib/3/imp.pyi @@ -46,9 +46,9 @@ def load_compiled(name: str, pathname: str, file: Optional[IO[Any]] = ...) -> ty def load_package(name: str, path: _Path) -> types.ModuleType: ... def load_module(name: str, file: IO[Any], filename: str, details: Tuple[str, str, int]) -> types.ModuleType: ... if sys.version_info >= (3, 6): - def find_module(name: str, path: Union[None, List[str], List[os.PathLike[str]], List[_Path]] = ...) -> Tuple[str, str, Tuple[IO[Any], str, int]]: ... + def find_module(name: str, path: Union[None, List[str], List[os.PathLike[str]], List[_Path]] = ...) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ... else: - def find_module(name: str, path: Optional[List[str]] = ...) -> Tuple[str, str, Tuple[IO[Any], str, int]]: ... + def find_module(name: str, path: Optional[List[str]] = ...) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ... def reload(module: types.ModuleType) -> types.ModuleType: ... def init_builtin(name: str) -> Optional[types.ModuleType]: ... def load_dynamic(name: str, path: str, file: Optional[IO[Any]] = ...) -> types.ModuleType: ...