Skip to content

Commit de9e7ee

Browse files
committed
Update how file's security metadata is retrieved following changes in the API response (#2621)
* Update security key name and BlobSecurityInfo object * typos * small typo * add comment * fix typo again
1 parent 812971b commit de9e7ee

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/huggingface_hub/hf_api.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ def __post_init__(self): # hack to make BlobLfsInfo backward compatible
336336

337337
@dataclass
338338
class BlobSecurityInfo(dict):
339-
safe: bool
339+
safe: bool # duplicate information with "status" field, keeping it for backward compatibility
340+
status: str
340341
av_scan: Optional[Dict]
341342
pickle_import_scan: Optional[Dict]
342343

@@ -656,10 +657,14 @@ def __init__(self, **kwargs):
656657
oid=last_commit["id"], title=last_commit["title"], date=parse_datetime(last_commit["date"])
657658
)
658659
self.last_commit = last_commit
659-
security = kwargs.pop("security", None)
660+
security = kwargs.pop("securityFileStatus", None)
660661
if security is not None:
662+
safe = security["status"] == "safe"
661663
security = BlobSecurityInfo(
662-
safe=security["safe"], av_scan=security["avScan"], pickle_import_scan=security["pickleImportScan"]
664+
safe=safe,
665+
status=security["status"],
666+
av_scan=security["avScan"],
667+
pickle_import_scan=security["pickleImportScan"],
663668
)
664669
self.security = security
665670

0 commit comments

Comments
 (0)