mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
complete stubs for imp (#1193)
* complete stubs for imp Helps fix #1115 * fix import
This commit is contained in:
committed by
Łukasz Langa
parent
e3f495b7e9
commit
5f2f96340f
22
stdlib/3/_imp.pyi
Normal file
22
stdlib/3/_imp.pyi
Normal file
@@ -0,0 +1,22 @@
|
||||
# Stubs for _imp (Python 3.6)
|
||||
|
||||
import sys
|
||||
import types
|
||||
from typing import Any, List
|
||||
|
||||
if sys.version_info >= (3, 5):
|
||||
from importlib.machinery import ModuleSpec
|
||||
def create_builtin(spec: ModuleSpec) -> types.ModuleType: ...
|
||||
def create_dynamic(spec: ModuleSpec, file: Any = ...) -> None: ...
|
||||
|
||||
def acquire_lock() -> None: ...
|
||||
def exec_builtin(mod: types.ModuleType) -> int: ...
|
||||
def exec_dynamic(mod: types.ModuleType) -> int: ...
|
||||
def extension_suffixes() -> List[str]: ...
|
||||
def get_frozen_object(name: str) -> types.CodeType: ...
|
||||
def init_frozen(name: str) -> types.ModuleType: ...
|
||||
def is_builtin(name: str) -> int: ...
|
||||
def is_frozen(name: str) -> bool: ...
|
||||
def is_frozen_package(name: str) -> bool: ...
|
||||
def lock_held() -> bool: ...
|
||||
def release_lock() -> None: ...
|
||||
@@ -1,10 +1,55 @@
|
||||
# Stubs for imp
|
||||
# Stubs for imp (Python 3.6)
|
||||
|
||||
# NOTE: These are incomplete!
|
||||
import os
|
||||
import sys
|
||||
import types
|
||||
from typing import Any, IO, List, Optional, Tuple, TypeVar, Union
|
||||
|
||||
from typing import TypeVar
|
||||
from _imp import (lock_held as lock_held, acquire_lock as acquire_lock, release_lock as release_lock,
|
||||
get_frozen_object as get_frozen_object, is_frozen_package as is_frozen_package,
|
||||
init_frozen as init_frozen, is_builtin as is_builtin, is_frozen as is_frozen)
|
||||
|
||||
if sys.version_info >= (3, 5):
|
||||
from _imp import create_dynamic as create_dynamic
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
def cache_from_source(path: str, debug_override: bool = ...) -> str: ...
|
||||
def reload(module: _T) -> _T: ... # TODO imprecise signature
|
||||
if sys.version_info >= (3, 6):
|
||||
_Path = Union[str, os.PathLike[str]]
|
||||
else:
|
||||
_Path = str
|
||||
|
||||
SEARCH_ERROR: int
|
||||
PY_SOURCE: int
|
||||
PY_COMPILED: int
|
||||
C_EXTENSION: int
|
||||
PY_RESOURCE: int
|
||||
PKG_DIRECTORY: int
|
||||
C_BUILTIN: int
|
||||
PY_FROZEN: int
|
||||
PY_CODERESOURCE: int
|
||||
IMP_HOOK: int
|
||||
|
||||
def new_module(name: str) -> types.ModuleType: ...
|
||||
def get_magic() -> bytes: ...
|
||||
def get_tag() -> str: ...
|
||||
def cache_from_source(path: _Path, debug_override: Optional[bool] = ...) -> str: ...
|
||||
def source_from_cache(path: _Path) -> str: ...
|
||||
def get_suffixes() -> List[Tuple[str, str, int]]: ...
|
||||
|
||||
class NullImporter:
|
||||
def __init__(self, path: _Path) -> None: ...
|
||||
def find_module(self, fullname: Any) -> None: ...
|
||||
|
||||
# PathLike doesn't work for the pathname argument here
|
||||
def load_source(name: str, pathname: str, file: Optional[IO[Any]] = ...) -> types.ModuleType: ...
|
||||
def load_compiled(name: str, pathname: str, file: Optional[IO[Any]] = ...) -> types.ModuleType: ...
|
||||
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]]: ...
|
||||
else:
|
||||
def find_module(name: str, path: Optional[List[str]] = ...) -> Tuple[str, str, Tuple[IO[Any], 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: ...
|
||||
|
||||
Reference in New Issue
Block a user