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

This commit is contained in:
Brandt Bucher
2018-12-03 12:26:37 -08:00
committed by Sebastian Rittau
parent bee236fb5d
commit ac8f5da324

View File

@@ -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
@@ -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: ...