Skip to content

Commit 9af05ac

Browse files
YosuaMichaelfacebook-github-bot
authored andcommitted
[fbsync] Try to fix mypy issue with calculate_md5 (#6493)
Reviewed By: NicolasHug Differential Revision: D39131019 fbshipit-source-id: 926d5ad1055dc9e95c5f9f42382a506e1b604383
1 parent 2ee15c7 commit 9af05ac

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

torchvision/datasets/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ def calculate_md5(fpath: str, chunk_size: int = 1024 * 1024) -> str:
6565
# Setting the `usedforsecurity` flag does not change anything about the functionality, but indicates that we are
6666
# not using the MD5 checksum for cryptography. This enables its usage in restricted environments like FIPS. Without
6767
# it torchvision.datasets is unusable in these environments since we perform a MD5 check everywhere.
68-
md5 = hashlib.md5(**dict(usedforsecurity=False) if sys.version_info >= (3, 9) else dict())
68+
if sys.version_info >= (3, 9):
69+
md5 = hashlib.md5(usedforsecurity=False)
70+
else:
71+
md5 = hashlib.md5()
6972
with open(fpath, "rb") as f:
7073
for chunk in iter(lambda: f.read(chunk_size), b""):
7174
md5.update(chunk)

0 commit comments

Comments
 (0)