Skip to content

Commit 35bdbf3

Browse files
fix: qualify HASH_PATTERN reference in RenderBuffer._ensure_hash (fixes #692) (#694)
Co-authored-by: apoorv-narayanam <nvcapoorv1234@gmail.com>
1 parent b4829d7 commit 35bdbf3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

preswald/engine/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
import hashlib
12
import json
23
import logging
4+
import re
35
import zlib
46
from datetime import date, datetime
5-
from typing import Any, Dict, List, Union
6-
import hashlib
7+
from typing import Any
8+
79
import msgpack
810
import numpy as np
9-
import re
1011

1112

1213
logger = logging.getLogger(__name__)
@@ -198,7 +199,7 @@ class RenderBuffer:
198199
HASH_PATTERN = re.compile(r"^[0-9a-f]{64}$")
199200

200201
def __init__(self):
201-
self._state_cache: Dict[str, str] = {}
202+
self._state_cache: dict[str, str] = {}
202203

203204
def has_changed(self, component_id: str, new_value: Any) -> bool:
204205
"""Check if the new hash differs from the cached one."""
@@ -223,7 +224,7 @@ def should_render(self, component_id: str, new_value: Any) -> bool:
223224

224225
def _ensure_hash(self, value: Any) -> str:
225226
"""Convert value to SHA256 hash. Accepts either a hash string or a hashable object."""
226-
if isinstance(value, str) and HASH_PATTERN.match(value):
227+
if isinstance(value, str) and self.HASH_PATTERN.match(value):
227228
return value # already a hash
228229
try:
229230
cleaned = clean_nan_values(value)

0 commit comments

Comments
 (0)