From 7cd4c99862000e69f347e5274b2e85f042465ab8 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 12 Sep 2024 19:27:54 -0400 Subject: [PATCH] Fix typing check - move assert before use of fp.tell() + shorten the message while at it --- dandi/download.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dandi/download.py b/dandi/download.py index e1ab4b60b..e14a7353a 100644 --- a/dandi/download.py +++ b/dandi/download.py @@ -867,10 +867,10 @@ def __exit__( exc_val: BaseException | None, exc_tb: TracebackType | None, ) -> None: + assert self.fp is not None if exc_type is not None or exc_val is not None or exc_tb is not None: lgr.debug( - "%s - entered __exit__ with current position %d with exception: " - "%s, %s, %s", + "%s - entered __exit__ with position %d with exception: " "%s, %s, %s", self.dirpath, self.fp.tell(), exc_type, @@ -879,11 +879,10 @@ def __exit__( ) else: lgr.debug( - "%s - entered __exit__ with current position %d without any exception", + "%s - entered __exit__ with position %d without any exception", self.dirpath, self.fp.tell(), ) - assert self.fp is not None self.fp.close() try: if exc_type is None: