From 9b8adc3bf58694b139b75e19f51e31cff572d32d Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Wed, 3 Jun 2020 16:55:50 -0500 Subject: [PATCH] Add PEP561 type annotation stubs for a few objects --- pytools/__init__.pyi | 20 ++++++++++++++++++++ pytools/py.typed | 0 setup.py | 2 ++ 3 files changed, 22 insertions(+) create mode 100644 pytools/__init__.pyi create mode 100644 pytools/py.typed diff --git a/pytools/__init__.pyi b/pytools/__init__.pyi new file mode 100644 index 0000000..f2961ac --- /dev/null +++ b/pytools/__init__.pyi @@ -0,0 +1,20 @@ +from typing import Any, Iterable, Optional, Set, TypeVar +from numbers import Number + +T = TypeVar("T") + +def one(iterable: Iterable[T]) -> T: ... +def is_single_valued(iterable: Iterable[T], equality_pred: Callable[[T, T], bool] = ...) -> bool: ... +all_equal = is_single_valued +def all_roughly_equal(iterable: Iterable[Number], threshold: Number) -> bool: ... +def single_valued(iterable: Iterable[T], equality_pred: Callable[[T, T], bool] = ...) -> T: ... + +def memoize(*args: T, **kwargs: Any) -> T: ... +def memoize_method(method: T) -> T: ... + +class UniqueNameGenerator: + def __init__(self, existing_names: Optional[Set[str]] = ..., forced_prefix: str = ...) -> None: ... + def __call__(self, based_on: str = ...) -> str: ... + def is_name_conflicting(self, name: str) -> bool: ... + def add_name(self, name: str) -> bool: ... + def add_names(self, name: Iterable[str]) -> bool: ... diff --git a/pytools/py.typed b/pytools/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py index adba753..1023096 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,8 @@ setup(name="pytools", "numpy>=1.6.0", ], + package_data={"pytools": ["py.typed", "__init__.pyi"]}, + author="Andreas Kloeckner", url="http://pypi.python.org/pypi/pytools", author_email="inform@tiker.net", -- GitLab