Skip to content

Commit

Permalink
ENH: provide descriptive assertion error on attempts_allowed_or_not
Browse files Browse the repository at this point in the history
Somehow, with some prior version of the code, but we did
get this assertion triggered as shown in
#1549 (comment)
although it remains unclear how that could have happened if type checking
is correct since we must not end up there with None or even 0.

Unfortunately with a regular assert we just get an announcement of the fact
and no details.  After this change we hope to be able to see more details
which might hint on the original issue.
  • Loading branch information
yarikoptic committed Dec 11, 2024
1 parent 38409e8 commit db4c0e1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dandi/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,10 @@ def _download_file(
yield {"status": "error", "message": str(exc)}
return
# for clear(er) typing, here we get only with int
assert isinstance(attempts_allowed_or_not, int)
assert isinstance(attempts_allowed_or_not, int), (

Check warning on line 786 in dandi/download.py

View check run for this annotation

Codecov / codecov/patch

dandi/download.py#L786

Added line #L786 was not covered by tests
f"attempts_allowed_or_not is {attempts_allowed_or_not!r} "
f"of type {type(attempts_allowed_or_not)}"
)
attempts_allowed = attempts_allowed_or_not
else:
lgr.warning("downloader logic: We should not be here!")
Expand Down

0 comments on commit db4c0e1

Please sign in to comment.