Skip to content

Commit

Permalink
Refactor code slightly to avoid assert + fix D400 ruff check for fina…
Browse files Browse the repository at this point in the history
…l period
  • Loading branch information
yarikoptic committed May 10, 2024
1 parent ba9db57 commit dff7f98
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dandiapi/api/management/commands/calculate_sha256.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit dff7f98

Please sign in to comment.