Files
gh-christianlouis-docuelevate/app/utils/file_operations.py
copilot-swe-agent[bot] 53a9efa56d feat: add strict mypy type-checking for app/utils/ module
- Add [[tool.mypy.overrides]] section for app/utils/** with disallow_untyped_defs=true
- Add type annotations to all functions in app/utils/ (12 files)
- Fix type annotations in app/config.py and app/database.py (imported by utils)
- All 85 source files now pass mypy type checking

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-14 00:27:52 +00:00

18 lines
480 B
Python

import hashlib
from pathlib import Path
def hash_file(filepath: str | Path, chunk_size: int = 65536) -> str:
"""
Returns the SHA-256 hash of the file at 'filepath'.
Reads the file in chunks to handle large files efficiently.
"""
sha256 = hashlib.sha256()
with open(filepath, "rb") as f:
while True:
data = f.read(chunk_size)
if not data:
break
sha256.update(data)
return sha256.hexdigest()