Skip to content

Commit 3111b39

Browse files
authored
Merge pull request #628 from bashtage/clean-code
TYP: Fix typing support
2 parents 7f29b34 + cfc6829 commit 3111b39

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

linearmodels/iv/absorbing.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from collections import defaultdict
44
from collections.abc import Hashable, Iterable
5-
from hashlib import sha256
5+
import hashlib
66
from typing import Any, DefaultDict, Union, cast
77
import warnings
88

@@ -70,18 +70,20 @@
7070

7171
class Hasher:
7272
def __init__(self):
73+
self._hasher: hashlib._Hash | xxh64
7374
if HAVE_XXHASH:
7475
self._hasher = xxh64()
75-
self._use_xx = True
76+
self._use_xxh64 = True
7677
else:
77-
self._hasher = sha256()
78-
self._use_xx = False
78+
self._hasher = hashlib.sha256()
79+
self._use_xxh64 = False
7980

8081
def reset(self):
81-
if self._use_xx:
82-
self._hasher = xxh64()
83-
else:
82+
if self._use_xxh64:
83+
assert isinstance(self._hasher, xxh64)
8484
self._hasher.reset()
85+
else:
86+
self._hasher = hashlib.sha256()
8587

8688
def update(self, data: memoryview) -> None:
8789
self._hasher.update(data)

0 commit comments

Comments
 (0)