Skip to content

Use TypeVar for pkgutil.extend_path #7473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2022
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
5 changes: 3 additions & 2 deletions stdlib/@python2/pkgutil.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Expand Down
6 changes: 4 additions & 2 deletions stdlib/pkgutil.pyi
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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: ...
Expand Down