Skip to content

Replace Loader with PEP 451 _Loader protocol in _importlib_modulespec.pyi annotations. #2626

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 2 commits into from
Dec 3, 2018
Merged
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
11 changes: 8 additions & 3 deletions stdlib/3/_importlib_modulespec.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@
# - ModuleType in types
# - Loader in importlib.abc
# - ModuleSpec in importlib.machinery (3.4 and later only)
#
# _Loader is the PEP-451-defined interface for a loader type/object.

from abc import ABCMeta
import sys
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Protocol

class _Loader(Protocol):
def load_module(self, fullname: str) -> ModuleType: ...

class ModuleSpec:
def __init__(self, name: str, loader: Optional[Loader], *,
origin: Optional[str] = ..., loader_state: Any = ...,
is_package: Optional[bool] = ...) -> None: ...
name = ... # type: str
loader = ... # type: Optional[Loader]
loader = ... # type: Optional[_Loader]
origin = ... # type: Optional[str]
submodule_search_locations = ... # type: Optional[List[str]]
loader_state = ... # type: Any
Expand All @@ -26,7 +31,7 @@ class ModuleType:
__name__ = ... # type: str
__file__ = ... # type: str
__dict__ = ... # type: Dict[str, Any]
__loader__ = ... # type: Optional[Loader]
__loader__ = ... # type: Optional[_Loader]
__package__ = ... # type: Optional[str]
__spec__ = ... # type: Optional[ModuleSpec]
def __init__(self, name: str, doc: Optional[str] = ...) -> None: ...
Expand Down