From 3398a031bf303465a2be80bcd14343afb368273c Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sat, 1 Aug 2020 15:38:01 -0700 Subject: [PATCH] Add type hints for @typechecked --- pytypes/py.typed | 0 pytypes/typechecker.pyi | 48 +++++++++++++++++++++++++++++++++++++++++ setup.cfg | 3 +++ 3 files changed, 51 insertions(+) create mode 100644 pytypes/py.typed create mode 100644 pytypes/typechecker.pyi diff --git a/pytypes/py.typed b/pytypes/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pytypes/typechecker.pyi b/pytypes/typechecker.pyi new file mode 100644 index 0000000..a4d86f2 --- /dev/null +++ b/pytypes/typechecker.pyi @@ -0,0 +1,48 @@ +# Generated using mypy stubgen, then editing types for typechecked and +# no_type_check. + +import __builtin__ as builtins +import types +import typing +from . import type_util as type_util, util as util +from .exceptions import InputTypeError as InputTypeError, OverrideError as OverrideError, ReturnTypeError as ReturnTypeError +from .type_util import TypeAgent as TypeAgent, deep_type as deep_type, get_orig_class as get_orig_class, has_type_hints as has_type_hints, is_Tuple as is_Tuple, is_builtin_type as is_builtin_type, type_str as type_str +from .util import getargspecs as getargspecs +from typing import Any, Optional, Callable, TypeVar, Union, overload +from warnings import warn as warn + +_python___import__ = builtins.__import__ + +def _pytypes___import__(name: Any, globls: Optional[Any] = ..., locls: Optional[Any] = ..., fromlist: Any = ..., level: int = ...): ... + +class _DelayedCheck: + func: Any = ... + method: Any = ... + class_name: Any = ... + base_method: Any = ... + base_class: Any = ... + exc_info: Any = ... + raising_module_name: Any = ... + def __init__(self, func: Any, method: Any, class_name: Any, base_method: Any, base_class: Any, exc_info: Any) -> None: ... + def run_check(self, raise_NameError: bool = ...) -> None: ... + +def override(func: Any, auto: bool = ...): ... +def typechecked_func(func: Any, force: bool = ..., argType: Optional[Any] = ..., resType: Optional[Any] = ..., prop_getter: bool = ...): ... +def typechecked_class(cls, force: bool = ..., force_recursive: bool = ...): ... +def typechecked_module(md: Any, force_recursive: bool = ...): ... + +T = TypeVar('T', Callable, property, type, types.ModuleType) +@overload +def typechecked(memb: str) -> Union[str, types.ModuleType]: ... +@overload +def typechecked(memb: T) -> T: ... +def auto_override_class(cls, force: bool = ..., force_recursive: bool = ...): ... +def auto_override_module(md: Any, force_recursive: bool = ...): ... +def auto_override(memb: Any): ... +def no_type_check(memb: T) -> T: ... +def is_no_type_check(memb: Any): ... +def check_argument_types(cllable: Optional[Any] = ..., call_args: Optional[Any] = ..., clss: Optional[Any] = ..., caller_level: int = ...): ... +def check_return_type(value: Any, cllable: Optional[Any] = ..., clss: Optional[Any] = ..., caller_level: int = ...): ... + +class TypeChecker(TypeAgent): + def __init__(self, all_threads: bool = ...) -> None: ... diff --git a/setup.cfg b/setup.cfg index a3cb69a..4776d81 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,6 @@ max-line-length = 99 [wheel] universal = 1 + +[options.package_data] +pytypes = py.typed, *.pyi