From b39cfb5276d2ee6c71103aaa93c8d924fd182ede Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 10 May 2024 10:31:21 -0400 Subject: [PATCH] Refactor code slightly to avoid assert + fix D400 ruff check for final period --- dandiapi/api/management/commands/calculate_sha256.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dandiapi/api/management/commands/calculate_sha256.py b/dandiapi/api/management/commands/calculate_sha256.py index d7f0507e8..f5c7e2722 100644 --- a/dandiapi/api/management/commands/calculate_sha256.py +++ b/dandiapi/api/management/commands/calculate_sha256.py @@ -10,18 +10,16 @@ @click.option('--blob-id', 'blob_id', help='Blob ID') @click.option('--asset-id', 'asset_id', help='Asset ID') def calculate_sha256(asset_id: str | None = None, blob_id: str | None = None): - """Trigger computation of sha256 for a blob + """Trigger computation of sha256 for a blob. Either blob-id or asset-id should be provided. """ if not asset_id and not blob_id: raise ValueError('Provide either asset_id or blob_id') - if asset_id and blob_id: - raise ValueError('Provide only asset_id or blob_id, not both') - - if not blob_id: - assert asset_id + if asset_id: + if blob_id: + raise ValueError('Provide only asset_id or blob_id, not both') asset = Asset.objects.get(asset_id=asset_id) blob_id = asset.blob_id