Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

utils: Fix make_safe_digest type safety.

Anders Kaseorgae7a21834e54
diff --git a/zerver/lib/utils.py b/zerver/lib/utils.py
index 36051e20bc8..bd60c2d2edf 100644
--- a/zerver/lib/utils.py
+++ b/zerver/lib/utils.py
@@ -1,10 +1,13 @@
import hashlib
import re
import secrets
-from typing import Any, Callable, List, Optional, TypeVar
+from typing import TYPE_CHECKING, Any, Callable, List, Optional, TypeVar
from django.conf import settings
+if TYPE_CHECKING:
+ from hashlib import _Hash
+
T = TypeVar("T")
@@ -55,7 +58,7 @@ class StatsDWrapper:
statsd = StatsDWrapper()
-def make_safe_digest(string: str, hash_func: Callable[[bytes], Any] = hashlib.sha1) -> str:
+def make_safe_digest(string: str, hash_func: "Callable[[bytes], _Hash]" = hashlib.sha1) -> str:
"""
return a hex digest of `string`.
"""