From 885f69ec3d96b8c453866bf593e56f5f127fabc9 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl <alexfikl@gmail.com> Date: Wed, 26 Jun 2024 10:38:58 +0300 Subject: [PATCH] add naive typing to unordered_hash --- pytools/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pytools/__init__.py b/pytools/__init__.py index 27e4bca..2304462 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -2768,7 +2768,9 @@ def resolve_name(name): # {{{ unordered_hash -def unordered_hash(hash_instance, iterable, hash_constructor=None): +def unordered_hash(hash_instance: Any, + iterable: Iterable[Any], + hash_constructor: Optional[Callable[[], Any]] = None) -> Any: """Using a hash algorithm given by the parameter-less constructor *hash_constructor*, return a hash object whose internal state depends on the entries of *iterable*, but not their order. If *hash* @@ -2794,6 +2796,8 @@ def unordered_hash(hash_instance, iterable, hash_constructor=None): from functools import partial hash_constructor = partial(hashlib.new, hash_instance.name) + assert hash_constructor is not None + h_int = 0 for i in iterable: h_i = hash_constructor() -- GitLab