From 0629d134fc521a3982dc308cd9cddcb539079870 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Thu, 10 Mar 2022 13:30:04 +0100 Subject: [PATCH] Use TypeVar for pkgutil.extend_path --- stdlib/@python2/pkgutil.pyi | 5 +++-- stdlib/pkgutil.pyi | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/stdlib/@python2/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index 3b006b376641..8b54a72ec0f3 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -1,13 +1,14 @@ from _typeshed import SupportsRead -from typing import IO, Any, Callable, Iterable, Iterator, Union +from typing import IO, Any, Callable, Iterable, Iterator, TypeVar, Union Loader = Any MetaPathFinder = Any PathEntryFinder = Any +_PathT = TypeVar("_PathT", bound=Iterable[str]) _ModuleInfoLike = tuple[Union[MetaPathFinder, PathEntryFinder], str, bool] -def extend_path(path: list[str], name: str) -> list[str]: ... +def extend_path(path: _PathT, name: str) -> _PathT: ... class ImpImporter: def __init__(self, path: str | None = ...) -> None: ... diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index 607c6b371507..7c27f6702a7e 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import SupportsRead from importlib.abc import Loader, MetaPathFinder, PathEntryFinder -from typing import IO, Any, Callable, Iterable, Iterator, NamedTuple +from typing import IO, Any, Callable, Iterable, Iterator, NamedTuple, TypeVar __all__ = [ "get_importer", @@ -18,12 +18,14 @@ __all__ = [ "ModuleInfo", ] +_PathT = TypeVar("_PathT", bound=Iterable[str]) + class ModuleInfo(NamedTuple): module_finder: MetaPathFinder | PathEntryFinder name: str ispkg: bool -def extend_path(path: list[str], name: str) -> list[str]: ... +def extend_path(path: _PathT, name: str) -> _PathT: ... class ImpImporter: def __init__(self, path: str | None = ...) -> None: ...