From db4c0e1eafdc5cc269e051380b8b824d1271d75f Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 11 Dec 2024 15:25:12 -0500 Subject: [PATCH] ENH: provide descriptive assertion error on attempts_allowed_or_not Somehow, with some prior version of the code, but we did get this assertion triggered as shown in https://github.com/dandi/dandi-cli/issues/1549#issuecomment-2537027028 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. --- dandi/download.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dandi/download.py b/dandi/download.py index 235381420..d1bf4234b 100644 --- a/dandi/download.py +++ b/dandi/download.py @@ -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), ( + 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!")