Add type hints; algo doesn’t need to be configurable
- ID
c652eb9- date
2025-02-10 17:10:58+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
8ef9cc3- message
Add type hints; algo doesn't need to be configurable- changed files
1 file, 5 additions, 4 deletions
Changed files
expansions/create_hash.py (287) → expansions/create_hash.py (297)
diff --git a/expansions/create_hash.py b/expansions/create_hash.py
index 5950741..7385e06 100644
--- a/expansions/create_hash.py
+++ b/expansions/create_hash.py
@@ -1,14 +1,15 @@
import hashlib
+from pathlib import Path
-def create_hash(path, *, algorithm=hashlib.sha256):
+def create_hash(path: Path) -> "hashlib._Hash":
"""
- Returns the hex checksum of the given path.
+ Returns the checksum of the given path.
"""
- h = algorithm()
+ h = hashlib.sha256()
with open(path, "rb") as infile:
while chunk := infile.read(8192):
h.update(chunk)
- return h.hexdigest()
+ return h