Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions codeflash/discovery/discover_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ def get_function_to_test_map_for_file(
return result

@staticmethod
def compute_file_hash(path: str | Path) -> str:
def compute_file_hash(path: Path) -> str:
h = hashlib.sha256(usedforsecurity=False)
with Path(path).open("rb") as f:
with path.open("rb", buffering=0) as f:
buf = bytearray(8192)
mv = memoryview(buf)
while True:
chunk = f.read(8192)
if not chunk:
n = f.readinto(mv)
if n == 0:
break
h.update(chunk)
h.update(mv[:n])
return h.hexdigest()

def close(self) -> None:
Expand Down
Loading